Announcement

Collapse
No announcement yet.

Simple Sales Report Export

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Simple Sales Report Export

    Maybe I'm just overlooking this but how do you create (and export) a Sale Report that has:

    Order #
    Date
    Customer Name
    Total Sales

    Something this simple should be doable.
    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

    #2
    Here's a page template that I wrote for another project. It generates a very simple report of sales for the last 30 days; you can change the time frame by modifying the variable g.ndays. It doesn't include the customer name, but I think you can figure out how to add that.
    Code:
    <html>
    <body>
    <center>
    
    <h1> New orders for &mvt:global:Store:name; </h1>
    
    <mvt:assign name="g.ndays" value="30" />
    <mvt:assign name="g.nsecs" value="g.ndays * 24 * 60 * 60" />
    <mvt:assign name="l.startdate" value="s.time_t - g.nsecs" />
    
    <h2> Last &mvt:global:ndays; day(s), as of <mvt:eval expr="s.tm_mon $ '/' $ s.tm_mday $ '/' $ s.tm_year" /> </h2>
    
    
    <mvt:do file="g.Module_Library_DB" name="l.no"
     value="OrderList_Load_Offset(0, '', '', 100, l.nextoffset, l.settings:orders)" />
    
    <p> <mvt:eval expr="l.no $ ' order(s) read.'" /> </p>
    
    
    <mvt:foreach array="orders" iterator="order">
        <mvt:if expr="l.settings:order:orderdate LT l.startdate">
            <mvt:foreachstop/>
        </mvt:if>
    
        <mvt:assign name="g.no" value="g.no + 1" />
    </mvt:foreach>
    
    <h3> &mvt:global:no; order(s) found in the specified date range </h3>
    
    <table border="1" cellspacing="0" cellpadding="4px">
    <tr>
    <th> Order No. </th>
    <th> Date </th>
    <th> Total </th>
    </tr>
    
    <mvt:foreach array="orders" iterator="order">
        <mvt:if expr="l.settings:order:orderdate LT l.startdate">
            <mvt:foreachstop/>
        </mvt:if>
    
        <mvt:assign name="l.year"    value="time_t_year(l.settings:order:orderdate, timezone())" />
        <mvt:assign name="l.month"    value="time_t_month(l.settings:order:orderdate, timezone())" />
        <mvt:assign name="l.mday"    value="time_t_dayofmonth(l.settings:order:orderdate, timezone())" />
        <mvt:assign name="l.hour"    value="time_t_hour(l.settings:order:orderdate, timezone())" />
        <mvt:assign name="l.minute"    value="time_t_min(l.settings:order:orderdate, timezone())" />
        <mvt:assign name="l.second"    value="time_t_sec(l.settings:order:orderdate, timezone())" />
    
        <tr>
        <td align="right"> &mvt:order:id; </td>
        <td> <mvt:eval expr="l.month $ '/' $ l.mday $ '/' $ l.year $ ' ' $ l.hour $ ':' $ l.minute $ ':' $ l.second" /> </td>
        <td> <mvt:eval expr="'$' $ l.settings:order:total ROUND 2" /> </td>
        </tr>
    </mvt:foreach>
    </table>
    
    <hr/>
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Thanks Kent. It does work great. Yes, I was able to figure out the customer name, but that got me thinking about the information being public. Now if it could export a file from within the admin
      Leslie Kirk
      Miva Certified Developer
      Miva Merchant Specialist since 1997
      Previously of Webs Your Way
      (aka Leslie Nord leslienord)

      Email me: [email protected]
      www.lesliekirk.com

      Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

      Comment


        #4
        Well, actually, I wrote that template as a test for a module I wrote to manage scheduled tasks. The module can run that template automatically once a day, or at some other interval, and email the results to one or more store managers. Let me know if your client is interested in that.

        Thanks --
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment


          #5
          Originally posted by lesliekirk View Post
          Thanks Kent. It does work great. Yes, I was able to figure out the customer name, but that got me thinking about the information being public. Now if it could export a file from within the admin
          There are several easy protection measures one can employ. Most basic is IP blocking, either by directly entering the s.remote_addr expression or using something like our Developer Sandbox tool (http://www.phosphormedia.com/product/pm_sandbox.html) (well, ok, using that--cause there isn't anything else like it).

          I've also done this by working off the Admin Session cookie. If present, meaning the individual is logged into the admin, the have access to the page. (I can send you that privately).
          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment

          Working...
          X