Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2006
    Posts
    87
    Plugin Contributions
    0

    Default I need a custom daily report of orders

    Hi everyone.
    I was wondering if someone could show me where to start if I wanted to get the following done. I know it's just a matter of calling the info from the database, but how do I go about it.

    Have a section in the backend of the site where:

    You put in ONE specific date such as 10/15/2009 in a text field
    and a report should generate a printable format like the one attached below with all the orders placed for that day.

    [SCR]http://aatechdesign.com/private/DailyReport.jpg[/SCR]

    Also if possible add the total of all the invoices for that day together somewhere at the bottom.

    Thanks in advance.
    Last edited by Kim; 21 Oct 2009 at 05:23 AM.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: I need a custom daily report of orders

    Did you look at the "Sales Report" addon?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Dec 2006
    Posts
    87
    Plugin Contributions
    0

    Default Re: I need a custom daily report of orders

    Thank you so much for the reply. We actually went ahead with this add-on "Export invoice totals to .csv file for Excel use" in:
    http://www.zen-cart.com/index.php?ma...roducts_id=170


    We have made some changes and everything works, except there are two fields we need to add to this that is getting pulled from the "customers" table rather than the "orders" table in the MySql database.

    The two fields we want is "customers_referral" and "customers_sales_person" (custom coded in there from before).

    Here's the full code page below:



    Code:
     
     
    <?php
    /**
     * /public_html/store/admin/export.php
     *
     * Export invoice data from Zend to Microsoft Excel CSV
     *
     * @author    Ahmed Chafik <ajchafik######################>
     * @copyright Cyberscraps 2006
     * @version   Define("Id: export.php,v 1 2006/06/21 21:24:53 Ahmed")
     *
     * Released under the terms and conditions of the
     * GNU General Public License (Version 2)
     *
     */
     require('includes/application_top.php');
     require(DIR_WS_CLASSES . 'currencies.php');
     $currencies = new currencies();
     if( isset($_POST['download_csv']) ) {
        Header('Content-type: application/csv');
        Header("Content-disposition: attachment; filename=\"Payments".date('mdy-Hi').".csv\"");
         $order = $db->execute("SELECT orders_id, date_purchased, payment_method,
                                       customers_name, customers_company, order_tax, order_total
                                  FROM ". TABLE_ORDERS ."
                                WHERE downloaded='no'
                                ORDER BY orders_id ASC");
         echo "Invoice No.,Date of Order,Payment Method,Customer Name,Customer Company,Tax,Total (excluding tax),Total (including tax),Sales Person,Shipped Date,Date Received\n";
         while( !$order->EOF ) {
           list( $invoice, $date, $method, $name, $customers_company, $tax, $total ) = array_values($order->fields);
    
           $get_tax = ((($total-5)/($total-5-$tax))-1)*100;
           preg_match('/^[0-9]{2}([0-9]{2})\-([0-9]{2})\-([0-9]{2}) .+$/', $date, $args);
           list( , $year, $month, $day ) = $args;
           echo "$invoice,".
                "$month/$day/$year,\"$method\",\"$name\",\"$customers_company\",\"".
                zen_display_tax_value($get_tax, true).'%","'.
                $currencies->format($total-$tax).'","'.
                $currencies->format($total). '","'. "Bob Smith" ."\"\n";
            $order->MoveNext();
         }
    /** Changed This By AA TECH to be able to keep downloading all files instead of only once. 
     **     $db->execute('UPDATE '. TABLE_ORDERS .' SET downloaded="yes" WHERE downloaded="no"');
     **/
         $db->execute('UPDATE '. TABLE_ORDERS .' SET downloaded="no" WHERE downloaded="no"');
    /** END OF IT HERE **/
    
       exit;
     }
    ?>
    <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html <?= HTML_PARAMS; ?>>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?= CHARSET; ?>">
    <title><?= TITLE; ?></title>
    <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
    <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
    <script language="javascript" src="includes/menu.js"></script>
    <script language="javascript" src="includes/general.js"></script>
    <script type="text/javascript">
      <!--
      function init()
      {
        cssjsmenu('navbar');
        if (document.getElementById)
        {
          var kill = document.getElementById('hoverJS');
          kill.disabled = true;
        }
      }
      // -->
    </script>
    </head>
    <body onload="init()">
    <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
    <table border="0" width="100%" cellspacing="2" cellpadding="2">
      <tr>
        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td class="pageHeading">Order History</td>
                <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr class="dataTableHeadingRow">
                    <td class="dataTableHeadingContent">Invoice No.</td>
                    <td class="dataTableHeadingContent">Date of Order</td>
                    <td class="dataTableHeadingContent">Payment Method</td>
                    <td class="dataTableHeadingContent">Customer Name</td>
                    <td class="dataTableHeadingContent">Customer Company</td>
                    <td class="dataTableHeadingContent">Tax</td>
                    <td class="dataTableHeadingContent">Total (excluding tax)</td>
                    <td class="dataTableHeadingContent" align="right">Total (including tax)&nbsp;</td>
        <!-- ADDED BY AA TECH -->
        <td class="dataTableHeadingContent" align="right">Sales Person &nbsp;</td>
        <td class="dataTableHeadingContent" align="right">Shipped Date &nbsp;</td>
        <td class="dataTableHeadingContent" align="right">Date Received &nbsp;</td>
        <!-- END OF - ADDED BY AA TECH -->
                  </tr>
    <?php
     $query = "SELECT orders_id, date_purchased, payment_method,
                      customers_name, customers_company, order_tax, order_total
               FROM ". TABLE_ORDERS ."
               ORDER BY orders_id ASC";
     $query = strtolower($query);
     $order_pages = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS_REPORTS, $query, $rows);
     $order = $db->execute($query);
     while( !$order->EOF ) {
       list( $invoice, $date, $method, $name, $customers_company, $tax, $total ) = array_values($order->fields);
    
       $get_tax = ((($total-5)/($total-5-$tax))-1)*100;
    ?>
                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="window.open('<?= zen_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $invoice, 'NONSSL'); ?>')">
                    <td class="dataTableContent" align="center"><?= $invoice; ?>&nbsp;&nbsp;</td>
                    <td class="dataTableContent"><?= zen_date_long($date) ?></td>
                    <td class="dataTableContent"><?= $method ?></td>
                    <td class="dataTableContent"><?= $name ?></td>
        <td class="dataTableContent"><?= $customers_company ?></td>
                    <td class="dataTableContent"><?= zen_display_tax_value($get_tax, true) ?>%</td>
                    <td class="dataTableContent"><?= $currencies->format($total-$tax); ?></td>
                    <td class="dataTableContent" align="right"><?= $currencies->format($total); ?>&nbsp;</td>
        <!-- ADDED BY AA TECH -->
    <td class="dataTableContent" align="center">Bob Smith</td>
    <td class="dataTableContent" align="center">&nbsp;&nbsp;</td>
    <td class="dataTableContent" align="center">&nbsp;&nbsp;</td>
        <!-- END OF - ADDED BY AA TECH -->
                  </tr>
    <?php
        $order->MoveNext();
      }
      if( !isset($invoice) ) {
      ?>
                  <tr class="dataTableRow">
                    <td class="dataTableContent" align="center" colspan="7"><b>No orders were found!</b></td>
                  </tr>
      <?
      }
    ?>
                </table></td>
              </tr>
              <tr>
                <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                    <td class="smallText" valign="top"><?php echo $order_pages->display_count($rows, MAX_DISPLAY_SEARCH_RESULTS_REPORTS, $_GET['page'], 'Displaying <b>%d</b> to <b>%d</b> (of <b>%d</b> orders)'); ?></td>
                    <td class="smallText" align="right"><?php echo $order_pages->display_links($rows, MAX_DISPLAY_SEARCH_RESULTS_REPORTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
                  </tr>
                </td>
                <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText" align="right">
                        <form name="download_csv" method="post">
                            <input style="font-weight: bold" name="download_csv" type="submit" value="Export to Excel Spreadsheet" />
                        </form>
                    </td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table>
    <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
    </body>
    </html>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
    "Bob Smith" is where the sales person's name from the table "customers" is going to go.

    I'm not really a MySQL savvy, but is there any way to include the other fields in this code here so we can call it.

    Code:
     
     
         $order = $db->execute("SELECT orders_id, date_purchased, payment_method,
                                       customers_name, customers_company, order_tax, order_total
                                  FROM ". TABLE_ORDERS ."
                                WHERE downloaded='no'
                                ORDER BY orders_id ASC");
    We have added the following info into the super orders invoice page module, and it works fine, but can't get it to to work for here.

    This is what we have in the super_invoice.php Page:

    Code:
     
     
    // Added Customer Number By AA TECH
      $sql = "SELECT o.customers_id, c.customers_referral from " . TABLE_ORDERS . " o, " . TABLE_CUSTOMERS . " c WHERE c.customers_id= o.customers_id and o.orders_id = '" . $oID . "'"; 
      $chk_customers_referral = $db->Execute($sql); 
      $customers_referral2 = $chk_customers_referral->fields['customers_referral'];  
    // Added Sales Person By AA TECH
      $sql = "SELECT o.customers_id, c.customers_sales_person from " . TABLE_ORDERS . " o, " . TABLE_CUSTOMERS . " c WHERE c.customers_id= o.customers_id and o.orders_id = '" . $oID . "'"; 
      $chk_customers_sales_person = $db->Execute($sql); 
      $customers_sales_person2 = $chk_customers_sales_person->fields['customers_sales_person'];

  4. #4
    Join Date
    Dec 2006
    Posts
    87
    Plugin Contributions
    0

    Default Re: I need a custom daily report of orders

    Can someone please let me know if this is an easy fix?


    can we add something like this:


    $order = $db->execute("SELECT orders_id, date_purchased, payment_method,
    customers_name, customers_company, order_tax, order_total
    FROM ". TABLE_ORDERS ." <-- [and perhaps add also From TABLE_CUSTOMERS so we can get some fields from there as well?]
    WHERE downloaded='no' <-- [Never mind this section]

    ORDER BY orders_id ASC");


    Thank you.
    Last edited by AATECH; 22 Oct 2009 at 09:58 PM.

 

 

Similar Threads

  1. Daily Order Report - Email?
    By JEKB in forum General Questions
    Replies: 0
    Last Post: 23 Aug 2010, 05:57 PM
  2. Custom report
    By END3RL3 in forum Customization from the Admin
    Replies: 2
    Last Post: 13 Jan 2010, 01:40 AM
  3. how do i download my daily orders to file??
    By charliesword in forum General Questions
    Replies: 5
    Last Post: 20 May 2009, 06:11 PM
  4. Need to Create a Report - Based on Orders
    By tirjasdyn in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 18 Jan 2009, 03:25 AM
  5. Looking for a Daily Sales Report
    By milobloom in forum General Questions
    Replies: 2
    Last Post: 12 Sep 2007, 03:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR