Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Order Tracker New Contrib....


jello1

Recommended Posts

Jared,

 

I am just changing the order status to Refunded which I set up as status 4. this why I can keep track of how much was refunded in a month or year. I have been trying to edit the file and subtract all the order status 4 from the total but so far no luck.

 

I would appreciate any help

 

Thanks,

Jeff

Link to comment
Share on other sites

  • Replies 260
  • Created
  • Last Reply

Top Posters In This Topic

Here is a question for ya. I have been searching in the modules for the closest match and yours seems to be the winner.

 

I need to find a mod that will sort all the customers who purchased a product. For example I'm selling tix to an event as a product and want to print out a list of all the customers names for a specific product.

 

Do you know if there is any modules out there or does your module do this already.

 

thanks

 

-D

Link to comment
Share on other sites

awesome!!!!!!!!!!!!!!!!!!!!!!!

 

thanks...... isn't that crazy it just came out. .....

 

I should ask for more things more often

Link to comment
Share on other sites

  • 3 weeks later...

I found one more reason why on the first day of the month yesterday's order summaries may not show.

 

find this:

 

    $last_month = $mo-1;
   if ( $last_month == 0) $last_month = 12; //if jan, then last month is dec (12th mo, not 0th month)
   $day = date('d') - 1;
   if ($day == "0") //today is the first day of the month, now "Thirty days hath November . . ." for the prev month
    { if ( ($last_month == 1) OR ($last_month == 3) OR ($last_month == 5) OR ($last_month == 7) OR ($last_month == 8) OR ($last_month == 10) OR ($last_month == 12) )
         $day = "31";
       elseif  ( ($last_month == 4) OR ($last_month == 6) OR ($last_month == 9) OR ($last_month == 11) )
         $day = "30";
//calculate Feb end day, including leap year calculation from http://www.mitre.org/tech/cots/LEAPCALC.html
       else {
             if ( ($year % 4) != 0) $day = "28";
              elseif ( ($year % 400) == 0) $day = "29";
              elseif ( ($year % 100) == 0) $day = "28";
              else $day = "29";
             }
    }

// next line to normalize $day format to 2 digits
   if ($day <10) {$day = "0$day";}
   $date = date('Y-m');
   $query = "SELECT * FROM orders WHERE date_purchased LIKE \"$date-$day%\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $l=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $l++;
   }
   mysql_free_result($result);
   $yesterday=$l;

 

and change it to this:

 

    $last_month = $mo-1;
   $yesterday_mo = date('m');
   if ( $last_month == 0) $last_month = 12; //if jan, then last month is dec (12th mo, not 0th month)
   { $day = date('d') - 1;
   }
   if ($day == "0") //today is the first day of the month, now "Thirty days hath November . . ." for the prev month
    { $yesterday_mo=$last_month;
      if ( ($last_month == 1) OR ($last_month == 3) OR ($last_month == 5) OR ($last_month == 7) OR ($last_month == 8) OR ($last_month == 10) OR ($last_month == 12) )
         $day = "31";
       elseif  ( ($last_month == 4) OR ($last_month == 6) OR ($last_month == 9) OR ($last_month == 11) )
         $day = "30";
//calculate Feb end day, including leap year calculation from http://www.mitre.org/tech/cots/LEAPCALC.html
       else {
             if ( ($year % 4) != 0) $day = "28";
              elseif ( ($year % 400) == 0) $day = "29";
              elseif ( ($year % 100) == 0) $day = "28";
              else $day = "29";
             }
    }

// next 2 lines to normalize $day and $yesterday_mo format to 2 digits
   if ($day <10) {$day = "0$day";}
   if ($yesterday_mo <10) {$yesterday_mo = "0$yesterday_mo";}

   $year = date('Y');
   $query = "SELECT * FROM orders WHERE date_purchased LIKE \"$year-$yesterday_mo-$day%\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $l=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $l++;
   }
   mysql_free_result($result);
   $yesterday=$l;

 

 

That should clear up some things. Let me know if you continue to have any problems at all.

 

-jared

Link to comment
Share on other sites

Shelly - - I duplicated your problem. If I place just one order, the order total doesn't show.

 

I'll see if I can fix it.

 

-jared

Link to comment
Share on other sites

Shelly - - I thought I duplicated your problem, but I was actually having another problem because of some code cleanup I've been doing tonight.

 

Mine actually works in exactly that circumstance. I'm nearly done with the cleanup, which will probably fix the issue you're seeing.

 

Depending on how my time goes in the next several days, I hope to release my latest version of this in the next week or so.

 

Changes (other than what I just posted several minutes ago) are not really feature improvements for the most part, rather code improvements.

 

For example, changing a variable named $yesterday to be something more representative of what it really is and does, like $yesterday_order_dollarvalue or something like that.

 

Then again, would anyone really be interested in using cleaned-up but identically-functional code?

 

-jared

Edited by jcall
Link to comment
Share on other sites

Hi - just a quick bit of feedback - I am new to OSC but have managed to muddle my way through a few contrib installs - and being a stats junkie - just love the sound of this one.

 

My problem lies in following the install instructions - as per your item 2 in install.txt

 

2) Edit /admin/fileames.php.  Add the following to the end of the file, just prior to the ?> line:

  define('FILENAME_STATS_ORDERS_TRACKING', 'orders_tracking.php'); to /admin/filenames.php

 

Now - I assume the correct name is filenames.php - however I don't have this file in my admin directory? I do have one called filenames.php in my admin/includes directory - but when I add the line of code to this directory I end up with -

when I try to access the report from orders tracking in admin

 

+ the following errors in my admin

 

Warning: Division by zero in /home/scrapbox/public_html/catalog/admin/includes/filenames.php on line 59

 

Warning: Division by zero in /home/scrapbox/public_html/catalog/admin/includes/filenames.php on line 59

 

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/scrapbox/public_html/catalog/admin/includes/filenames.php:59) in /home/scrapbox/public_html/catalog/admin/includes/functions/sessions.php on line 67

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/scrapbox/public_html/catalog/admin/includes/filenames.php:59) in /home/scrapbox/public_html/catalog/admin/includes/functions/sessions.php on line 67

 

Also - am I reading step 3. correctly

3) Save the followig as /admin/includes/language/english/orders_tracking.php:

  <?php

  define('HEADING_TITLE', 'Daily Sales Summary');

  define('HEADING_SELECT_YEAR', 'Enter Year');

  ?>

 

In that I should create a new file called orders_tracking.php and put this code into it and then save it to the english directory??

 

 

So as you can see I am all over the place and not sure what to do from here?

 

Any help would be appreciated.

 

cheers

Maria

Link to comment
Share on other sites

Hi further to my post above - I have managed to figure out that I cut and pasted your code including the bit on the end from step 2.

2) Edit /admin/fileames.php.  Add the following to the end of the file, just prior to the ?> line:

  define('FILENAME_STATS_ORDERS_TRACKING', 'orders_tracking.php'); to /admin/filenames.php

 

Which meant I got the "to /admin/filenames.php" on the end of the code and it obviously shouldn't have been there, when I delected this little bit of text from the

admin/includes/filename.php file - all the previously reported errors disappeared@!!

 

Just thought you may want to make a note that instructions are not all that clear for us newly initiated into Oscommerce - really need a oscommerce for dummies book!

 

Now I have to say what a fantastic contribution!!!

 

I am loving it - well done :D :D :D

Maria (aka stats junkie)

Link to comment
Share on other sites

sorry about the typo. I'll fix it with the cleaned-up code.

 

Kudos to the original author, Jello! All we've done since then was make it better together.

 

The cleaning-up, by the way, is taking a while, since I messed up a few things in my cleaning and had to revert to my non-cleaned up version to fix them.

 

One persistent think that I've not gotten figured out yet: All purchases now show up for me as repeat customers, stats-wise. I just haven't had the time to figure it out yet.

 

So, if any of you are seeing that same symptom, be assured that I'm aware of it, it annoys me, and I'll find some way to fix it unless someone else fixes it first.

 

-jared

Link to comment
Share on other sites

sorry about the typo. I'll fix it with the cleaned-up code.

 

Kudos to the original author, Jello! All we've done since then was make it better together.

 

The cleaning-up, by the way, is taking a while, since I messed up a few things in my cleaning and had to revert to my non-cleaned up version to fix them.

 

One persistent think that I've not gotten figured out yet: All purchases now show up for me as repeat customers, stats-wise. I just haven't had the time to figure it out yet.

 

So, if any of you are seeing that same symptom, be assured that I'm aware of it, it annoys me, and I'll find some way to fix it unless someone else fixes it first.

 

-jared

:o Thanks Jared... without you guys this would of never came about!...

<span style='font-family:Courier'>If you can't fix it Perl it!!!...</span>

******************************

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

Noob here and just finished installing this contribution. It seems to be working fine, but I have just made my site live and dont have a lot of orders to work with yet. The question I have is the Grand Totals show all my testing orders and I would like to delete them so I can start with a fresh sheet. How do I do that?

life is short "Eat Desert First"

Link to comment
Share on other sites

  • 1 month later...

Hey Guys,

I have just installed this contribution and it works but now I have some header problems.

 

The errors are;

 

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/seanni00/public_html/cart/oscommerce-2.2ms2/catalog/admin/includes/filenames.php:62) in /home/seanni00/public_html/cart/oscommerce-2.2ms2/catalog/admin/includes/functions/sessions.php on line 67

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/seanni00/public_html/cart/oscommerce-2.2ms2/catalog/admin/includes/filenames.php:62) in /home/seanni00/public_html/cart/oscommerce-2.2ms2/catalog/admin/includes/functions/sessions.php on line 67

 

 

Any of you experts out there have any thoughts on solving this problem

 

Thanks

Link to comment
Share on other sites

Farrukh -- I've cleaned up some variables, to make the code easier to understand if you want to change things. I'll post it to this thread later tonight and re-release it.

 

deroguy - this is probably an issue of having extra space at the end of the file. Check after the ?> line - - there should be no extra lines.

 

-jared

Link to comment
Share on other sites

here is it, with my debugging printouts at the end and my extra status codes. You can strip them out if you want, or not. I'll remove those before I release it as a contrib update.

 

-jared

 

<snip>

 

Sorry - - I noticed that I forgot to clean out a couple of the $k and $j variables - - should have them done tonight or early next week.

 

-jared

Edited by jcall
Link to comment
Share on other sites

ok - - fixed the last few remaining variable names, plus finally fixed the problem where the first of the month would not only show the wrong day for yesterday, but also show $0.00 in sales.

 

Here is the code, with some of my extra stuff in there. I'll remove that before posting the update as a contribution.

 

Enjoy!

 

<?php
 require('includes/application_top.php');

// TO-DO LIST
// finish loop code for month data?
// orders shipped this month/year -- way to do this without adding date field to orders_total?
// orders shipped this year -- way to do this without adding date field to orders_total?
// add calculation for gift vouchers?  This would sort of merge this report with the monthly sales/tax contrib's functionality
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr> 
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="dataTableContent"><br><br><?php
                echo tep_draw_form('search', FILENAME_STATS_ORDERS_TRACKING, '', 'get');
                echo HEADING_SELECT_YEAR . ' ' . tep_draw_input_field('year', '', 'size="4"');
                echo '   <input type="submit" value="Recalculate">';
                echo '</form>';
               ?><br><br>
           </td>

           <td class="pageHeading" align="right"><?php echo tep_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="0">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php
setlocale(LC_MONETARY, 'en_US');

function get_month($mo, $yr) {
   $query = "SELECT * FROM orders WHERE date_purchased LIKE \"$yr-$mo%\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $month=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
               $month++;
   }
   mysql_free_result($result);
   return $month;
}

function get_order_total($mo, $yr) {
   $query = "SELECT orders_id FROM orders WHERE date_purchased LIKE \"$yr-$mo%\" ORDER by orders_id";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $i=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
          if ( $i == 0 ) {
               $first=$col_value;
               $i++;
          } else {
               $last=$col_value;
          }
       }
   }
   mysql_free_result($result);

   $query = "SELECT sum(value) FROM orders_total WHERE orders_id >= \"$first\" and orders_id <= \"$last\" and class = \"ot_total\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
               $total=$col_value;
       }
   }
   mysql_free_result($result);
   return $total;
}

function get_status($type) {
   $query = "SELECT orders_status FROM orders WHERE orders_status = \"$type\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $orders_this_status=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
          $orders_this_status++;
	 }
   }
   mysql_free_result($result);
   return $orders_this_status;
}


# Get total dollars in orders

   $query = "SELECT sum(value) FROM orders_total WHERE class = \"ot_total\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
    $grand_total=$col_value;
       }
   }
   mysql_free_result($result);

   
# Get total shipping charges

   $query = "SELECT sum(value) FROM orders_total WHERE class like \"ot_shipping\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
    $shipping=$col_value;
       }
   }
   mysql_free_result($result);


# Get total number of customers
   $query = "SELECT * FROM customers";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $customer_count=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $customer_count++;
   }
   mysql_free_result($result);

   
# Get total number new customers

   $like = date('Y-m-d');
   $query = "SELECT customers_info_date_account_created FROM customers_info WHERE customers_info_date_account_created like \"$like%\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $newcust=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $newcust++;
   }
   mysql_free_result($result);

   
# Whos online

   $query = "SELECT * FROM whos_online";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $whos_online=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $whos_online++;
   }
   mysql_free_result($result);

   
# Whos online again

   $query = "SELECT * FROM whos_online WHERE customer_id != \"0\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $who_again=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $who_again++;
   }
   mysql_free_result($result);

   
# How many orders today total

   $date = date('Y-m-d'); #2003-09-07%
   $query = "SELECT * FROM orders WHERE date_purchased LIKE \"$date%\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $today_order_count=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $today_order_count++;
   }
   mysql_free_result($result);

   
# How many orders yesterday

   $mo = date('m');
   $today = date('d');
   $year = date('Y');
   
   $last_month = $mo-1;
   if ( $last_month == 0) $last_month = 12; //if jan, then last month is dec (12th mo, not 0th month)
   $yesterday = date('d') - 1;
   if ($yesterday == "0") //today is the first day of the month, now "Thirty days hath November . . ." for the prev month
    { if ( ($last_month == 1) OR ($last_month == 3) OR ($last_month == 5) OR ($last_month == 7) OR ($last_month == 8) OR ($last_month == 10) OR ($last_month == 12) )
         $yesterday = "31";
       elseif  ( ($last_month == 4) OR ($last_month == 6) OR ($last_month == 9) OR ($last_month == 11) )
         $yesterday = "30";
//calculate Feb end day, including leap year calculation from http://www.mitre.org/tech/cots/LEAPCALC.html
       else {
             if ( ($year % 4) != 0) $yesterday = "28";
              elseif ( ($year % 400) == 0) $yesterday = "29";
              elseif ( ($year % 100) == 0) $yesterday = "28";
              else $yesterday = "29";
             }
    }

// next line to normalize $yesterday format to 2 digits
   if ($yesterday <10) {$yesterday = "0$yesterday";}
   if ($last_month <10) {$last_month = "0$last_month";}
   $year = date('Y');
   $query = "SELECT * FROM orders WHERE date_purchased LIKE \"$year-$last_month-$yesterday%\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $yesterday_order_count=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
   $yesterday_order_count++;
   }
   mysql_free_result($result);

# Get the last order_id

   $query = "SELECT orders_id FROM orders_total WHERE class = \"ot_total\" ORDER BY orders_id ASC";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
 $latest_order_id=$col_value;
}
   }
   mysql_free_result($result);

   
# Calculate the order_id number less the number of orders today

   $yesterday_last_order_id = $latest_order_id - $today_order_count;
   $twodaysago_last_order_id = $yesterday_last_order_id - $yesterday_order_count;

   
# Grab the sum of all orders greater than $yesterday_last_order_id
# In other words, how much have we done so far in sales today?

   $query = "SELECT sum(value) FROM orders_total WHERE orders_id > \"$yesterday_last_order_id\" and class = \"ot_total\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
    $orders_today=$col_value;
       }
   }
   mysql_free_result($result);

   
# Grab the sum of all orders greater than $twodaysago_last_order_id and less than yesterday_last_order_id
# In other words, how much did we do in sales yesterday?

   $query = "SELECT sum(value) FROM orders_total WHERE orders_id > \"$twodaysago_last_order_id\" and orders_id <= \"$yesterday_last_order_id\" and class = \"ot_total\"";    
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
    $orders_yesterday=$col_value;
       }
   }
   mysql_free_result($result);

# How many repeat orders today total

   $date = date('Y-m-d');
   $query = "SELECT * FROM orders WHERE date_purchased LIKE \"$date%\" AND customers_id < \"$yesterday_last_order_id\"";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $repeat_orders=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 $repeat_orders++;
   }
   mysql_free_result($result);

# Find all repeat orders

   $date = date('Y-m-d');
   $query = "SELECT customers_id FROM orders ORDER by customers_id";
   $result = mysql_query($query) or die("Query failed : " . mysql_error());
   $repeats=0;
   while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
       foreach ($line as $col_value) {
    $cust_id=$col_value;
 if ( $cust_id == $cust_id_last ) {
 $repeats++;
 }
    $cust_id_last=$cust_id;
  	 }
   }
   mysql_free_result($result);


# How many per month

// if a year has been entered as part of the URL, use that year instead
   if (isset($HTTP_GET_VARS['year'])) $year=$HTTP_GET_VARS['year'];
     else $year = date('Y'); #current year

   
   $month = date('M'); #current month

   $dec = get_month("12", $year);
   $nov = get_month("11", $year);
   $oct = get_month("10", $year);
   $sep = get_month("09", $year);
   $aug = get_month("08", $year);
   $jul = get_month("07", $year);
   $jun = get_month("06", $year);
   $may = get_month("05", $year);
   $apr = get_month("04", $year);
   $mar = get_month("03", $year);
   $feb = get_month("02", $year);
   $jan = get_month("01", $year);
   $current_month = get_month($mo, $year);


# Only Process Month Info if Month has info to process
# Always tally totals, even if zero

# while ($i < 13)
# (
#   $month_avg = $month_total / $current_month;
#   $current_month_total = get_order_total($i, $year);
#   $order = $order + $current_month_total;
#   )
#   $i++;

$jan_total = get_order_total("01", $year);
if ($jan != 0)   $jan_avg = $jan_total / $jan;
$order = $order + $jan_total;

$feb_total = get_order_total("02", $year);
if ($feb != 0)  $feb_avg = $feb_total / $feb;
$order = $order + $feb_total;

$mar_total = get_order_total("03", $year);
if ($mar != 0)   $mar_avg = $mar_total / $mar;
$order = $order + $mar_total;

$apr_total = get_order_total("04", $year);
if ($apr != 0)   $apr_avg = $apr_total / $apr;
$order = $order + $apr_total;

$may_total = get_order_total("05", $year);
if ($may != 0)   $may_avg = $may_total / $may;
$order = $order + $may_total;

$jun_total = get_order_total("06", $year);
if ($jun != 0)   $jun_avg = $jun_total / $jun;
$order = $order + $jun_total;

$jul_total = get_order_total("07", $year);
if ($jul != 0)   $jul_avg = $jul_total / $jul;
$order = $order + $jul_total;

$aug_total = get_order_total("08", $year);
if ($aug != 0)   $aug_avg = $aug_total / $aug;
$order = $order + $aug_total;

$sep_total = get_order_total("09", $year);
if ($sep != 0)   $sep_avg = $sep_total / $sep;
$order = $order + $sep_total;

$oct_total = get_order_total("10", $year);
if ($oct != 0)   $oct_avg = $oct_total / $oct;
$order = $order + $oct_total;

$nov_total = get_order_total("11", $year);
if ($nov != 0)   $nov_avg = $nov_total / $nov;
$order = $order + $nov_total;

$dec_total = get_order_total("12", $year);
if ($dec != 0)   $dec_avg = $dec_total / $dec;
$order = $order + $dec_total;

$current_month_total = get_order_total($mo, $year);
if ($current_month != 0)   $current_month_avg = $current_month_total / $current_month;



# Order Status
   $received = get_status("1");
   $packed = get_status("2");
   $delivered = get_status("3");
// REMOVE NEXT LINE BEFORE RELEASING
   $shipped = get_status("4");
   $backordered = get_status("5");
   $hold = get_status("6");
   $preorder = get_status("8");
   $waiting = get_status("9");
   $waiting_customer = get_status("10");

# Daily Averages
if ($today_order_count !=0 )  $today_avg = $orders_today / $today_order_count;
 else $today_avg = 0;
if ($yesterday_order_count != 0) $yesterday_avg = $orders_yesterday / $yesterday_order_count;
 else ($yesterday_avg = 0);

$daily = $current_month / $today;
$daily_total = $current_month_total / $today;

if ($daily) $daily_avg = $daily_total / $daily;
 else ($daily_avg = 0);

# Calculate days in this month for accurate sales projection

if ( ($mo == 1) OR ($mo == 3) OR ($mo == 5) OR ($mo == 7) OR ($mo == 8) OR ($mo == 10) OR ($mo == 12) )
     $days_this_month = "31";
 elseif ( ($mo == 4) OR ($mo == 6) OR ($mo == 9) OR ($mo == 11) )
          $days_this_month = "30";
//calculate Feb end day, including leap year calculation from http://www.mitre.org/tech/cots/LEAPCALC.html
   else {
         if ( ($year % 4) != 0) $days_this_month = "28";
         elseif ( ($year % 400) == 0) $days_this_month = "29";
         elseif ( ($year % 100) == 0) $days_this_month = "28";
             else $days_this_month = "29";
        }

# Projected Profits this month
$projected = $daily * $days_this_month;
$projected_total = $daily_total * $days_this_month;

$gross_profit = $grand_total * .3;

$year_profit = $order * .3;

If ($newcust != 0) $close_ratio = $today_order_count / $newcust;
 else $close_ratio = 0;

# format test into current
       $total_orders = $jan + $feb + $mar + $apr + $may + $jun + $jul + $aug + $sep + $oct + $nov + $dec;
if ($total_orders != 0)   $total = $order / $total_orders;
$total = number_format($total,2,'.',',');

$order = number_format($order,2,'.',',');
$grand_total = number_format($grand_total,2,'.',',');

  	 $gross_profit = number_format($gross_profit,2,'.',',');
  	 $year_profit = number_format($year_profit,2,'.',',');

  	 $projected = number_format($projected,0,'.',',');
  	 $projected_total = number_format($projected_total,2,'.',',');

  	 $close_ratio = number_format($close_ratio,2,'.',',');

       $yesterday_avg = number_format($yesterday_avg,2,'.',',');

$dec_total = number_format($dec_total,2,'.',',');
$nov_total = number_format($nov_total,2,'.',',');
$oct_total = number_format($oct_total,2,'.',',');
$sep_total = number_format($sep_total,2,'.',',');
$aug_total = number_format($aug_total,2,'.',',');
$jul_total = number_format($jul_total,2,'.',',');
$jun_total = number_format($jun_total,2,'.',',');
$may_total = number_format($may_total,2,'.',',');
$apr_total = number_format($apr_total,2,'.',',');
$mar_total = number_format($mar_total,2,'.',',');
$feb_total = number_format($feb_total,2,'.',',');
$jan_total = number_format($jan_total,2,'.',',');


       $orders_today = number_format($orders_today,2,'.',',');
       $orders_yesterday = number_format($orders_yesterday,2,'.',',');

       $dec_avg = number_format($dec_avg,2,'.',',');
       $nov_avg = number_format($nov_avg,2,'.',',');
       $oct_avg = number_format($oct_avg,2,'.',',');
       $sep_avg = number_format($sep_avg,2,'.',',');
       $aug_avg = number_format($aug_avg,2,'.',',');
       $jul_avg = number_format($jul_avg,2,'.',',');
       $jun_avg = number_format($jun_avg,2,'.',',');
       $may_avg = number_format($may_avg,2,'.',',');
       $apr_avg = number_format($apr_avg,2,'.',',');
       $mar_avg = number_format($mar_avg,2,'.',',');
       $feb_avg = number_format($feb_avg,2,'.',',');
       $jan_avg = number_format($jan_avg,2,'.',',');

       $today_avg = number_format($today_avg,2,'.',',');

if ($total_orders !=0) $shipping_avg = $shipping / $total_orders;
 else $shipping_avg = 0;

       $shipping_avg = number_format($shipping_avg,2,'.',',');
       $shipping = number_format($shipping,2,'.',',');

  	 $daily = number_format($daily,2,'.',',');
  	 $daily_total = number_format($daily_total,2,'.',',');
  	 $daily_avg = number_format($daily_avg,2,'.',',');
?>

<CENTER>
<TABLE BORDER=1 CELLPADDING=5 CELLSPACING=1>
<TR class="dataTableHeadingRow" bgcolor=silver><th class="dataTableHeadingContent">Description<th class="dataTableHeadingContent">Order Count<th class="dataTableHeadingContent">Dollar<th class="dataTableHeadingContent">Average</TR>
<!-- <TR bgcolor=silver><TH>Description<TH>Order Count<TH>Dollar<TH>Average</TR> -->

<TR class="dataTableRow">
 <td class="dataTableContent" align="left"><A href="orders.php?selected_box=customers&status=1">Today <?php echo "$mo-$today"; ?></a></TD><td class="dataTableContent" align="left"><A href="orders.php?selected_box=customers&status=1"><?php echo "$today_order_count ($repeat_orders)"; ?> *</a></TD>
 <td class="dataTableContent" align=right>$<?php echo $orders_today ?></TD>
 <td class="dataTableContent" align=right>$<?php echo $today_avg ?></TD>
</TR>
<TR class="dataTableRow">
 <td class="dataTableContent">Yesterday <?php echo "$last_month-$yesterday"; ?></TD>
 <td class="dataTableContent"><?php echo $yesterday_order_count ?></TD>
 <td class="dataTableContent" align=right>$<?php echo $orders_yesterday ?></TD>
 <td class="dataTableContent" align=right>$<?php echo $yesterday_avg ?></TD>
</TR>
<TR class="dataTableRow">
 <td class="dataTableContent">Daily Average for <?php echo $month ?></TD>
 <td class="dataTableContent"><?php echo $daily ?></TD><td class="dataTableContent" align=right>$<?php echo $daily_total ?></TD>
 <td class="dataTableContent" align=right>$<?php echo $daily_avg ?></TD>
</TR>
<TR class="dataTableRow">
 <td class="dataTableContent">Projected #'s for <?php echo $month ?></TD>
 <td class="dataTableContent"><?php echo $projected ?></TD>
 <td class="dataTableContent" align=right>$<?php echo $projected_total ?></TD>
 <td class="dataTableContent" align=right> </TD>
</TR>


<TR class="dataTableHeadingRow" bgcolor=silver><td class="dataTableContent" class="dataTableHeadingContent" COLSPAN=4><b><center><br>Month Totals</b></center></TD></TR>


<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Jan <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $jan ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $jan_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $jan_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Feb <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $feb ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $feb_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $feb_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Mar <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $mar ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $mar_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $mar_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Apr <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $apr ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $apr_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $apr_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >May <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $may ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $may_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $may_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Jun <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $jun ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $jun_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $jun_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Jul <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $jul ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $jul_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $jul_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Aug <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $aug ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $aug_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $aug_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Sep <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $sep ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $sep_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $sep_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Oct <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $oct ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $oct_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $oct_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Nov <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $nov ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $nov_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $nov_avg ?></TD></TR>

<TR>
<TR class="dataTableRow"><td class="dataTableContent" >Dec <?php echo $year ?> Orders</TD><td class="dataTableContent" > <?php echo $dec ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $dec_total ?></TD>
<td class="dataTableContent"  align=right>$<?php echo $dec_avg ?></TD></TR>

<TR class="dataTableRow" >
<td class="dataTableContent" NOWRAP><B>Total <?php echo $year ?> Orders</TD><td class="dataTableContent"><B><?php echo "$total_orders / $repeats"; ?> *</TD><td class="dataTableContent" align=right><B>$<?php echo $order ?></TD><td class="dataTableContent" align=right><B>$<?php echo $total ?></TD></TR>
<TR class="dataTableRow" ><td class="dataTableContent"><B><?php echo $year ?> Profit @ 30%</TD><td class="dataTableContent" colspan=2 align=right><B>$<?php echo $year_profit ?></TD><td class="dataTableContent" align=right> </TD></TR>

<TR valign="bottom"><TD bgcolor=silver colspan=4></TD></TR>
<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/customers.php">Total Customers</a></TD><td class="dataTableContent"><?php echo $customer_count ?></TD><td class="dataTableContent"><A href="whos_online.php">Online Now</a></TD><td class="dataTableContent"><?php echo "$whos_online / $who_again"; ?> *</TD></TR>
<TR class="dataTableRow" ><td class="dataTableContent">New Customers Today</TD><td class="dataTableContent"><?php echo $newcust ?></TD><td class="dataTableContent">Close ratio</TD><td class="dataTableContent"><?php echo $close_ratio ?>%</TR>


<TR class="dataTableHeadingRow" bgcolor=silver><td class="dataTableContent" class="dataTableHeadingContent" COLSPAN=4><b><center><br>Order Status</b></center></TD></TR>


<!-- DOCUMENT/FIX BEFORE RELEASE 
<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=1">Orders Pending</a></TD><td class="dataTableContent"><?php echo $pending ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>
-->

<!-- REMOVE THIS ONE -->
<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=1">Orders Received</TD><td class="dataTableContent"><?php echo $received ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>
<!-- REMOVE THIS ONE -->

<!-- REMOVE THIS ONE -->
<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=2">Orders Packed</TD><td class="dataTableContent"><?php echo $packed ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>
<!-- REMOVE THIS ONE -->

<!-- 
<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=2">Orders Processing</TD><td class="dataTableContent">//<?php echo $processing ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>
-->

<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=3">Orders Delivered</TD><td class="dataTableContent"><?php echo $delivered ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>


<!-- REMOVE THE REST OF THESE -->
<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=4">Orders Shipped</TD><td class="dataTableContent"><?php echo $shipped ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=5">Orders Backordered</TD><td class="dataTableContent"><?php echo $backordered ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=6">Orders On Hold</TD><td class="dataTableContent"><?php echo $hold ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=8">Pre-Orders</TD><td class="dataTableContent"><?php echo $preorder ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=9">Waiting</TD><td class="dataTableContent"><?php echo $waiting ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><a href="/admin/orders.php?status=10">Waiting Customer Response</TD><td class="dataTableContent"><?php echo $waiting_customer ?></TD><td class="dataTableContent" colspan=2 align=right> </TD></TR>
<!-- END REMOVE THE REST OF THESE -->


<TR class="dataTableHeadingRow" bgcolor=silver><td class="dataTableContent" class="dataTableHeadingContent" COLSPAN=4><b><center><br>**Grand Totals</b></center></TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><B>Grand Total**</TD><td class="dataTableContent" colspan=2 align=right><B>$<?php echo $grand_total ?></TD><td class="dataTableContent" align=right> </TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><B>Gross Profit @ 30%</TD><td class="dataTableContent" colspan=2 align=right><B>$<?php echo $gross_profit ?></TD><td class="dataTableContent" align=right> </TD></TR>

<TR class="dataTableRow" ><td class="dataTableContent"><B>Shipping Charges</TD><td class="dataTableContent" colspan=2 align=right><B>$<?php echo $shipping ?></TD><td class="dataTableContent" align=right><B>$<?php echo $shipping_avg ?></TD></TR>



</TABLE>

<FONT SIZE=-1>
<br>
* - total / repeat customer
<BR>
** - Grand Totals since database inception.  Raw numbers pulled from database on select * from orders_total</FONT>


           </td>
         </tr>
       </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>


<!-- 
<br><br>
  orders_today: <?php echo $orders_today ?><br>
  today_order_count: <?php echo $today_order_count ?><br>
  yesterday_order_count: <?php echo $yesterday_order_count ?><br>
  yesterday_last_order_id: <?php echo $yesterday_last_order_id ?><br>
  latest_order_id: <?php echo $latest_order_id ?><br>
  twodaysago_last_order_id: <?php echo $twodaysago_last_order_id ?><br>
-->



<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
</body>
</html>

Link to comment
Share on other sites

added a little dynamic code to read the order status

enjoy

 

package is uploaded in contributions

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

RATS! I noticed this morning that the yesterday stat is messed up still. Mine shows that yesterday was 7/01. Grrr...

 

I'll fix that and re-release.

 

-jared

 

Druide - - thanks for the addition!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...