Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
Forum Search
Google Site Search
 All Forums
 Technical
 Tips and Tricks - HALL OF FAME
 Admin home stats - Sort by amt + Sales percentages
Author « Topic »  

dbdave
ECT Moderator

USA
10406 Posts

Posted - 01/31/2019 :  17:22:54  
===EDIT - ASP version in this post - PHP version below in another post===

I was poking around working on some stuff and looking in the (.asp version) incadmin.asp file and noticed the sql query for the top 10 sellers on the home page.
For a long time, I have wanted to show that based on amount instead of quantity.
The thing is, we have some products that are literally a few cents each. Customers order thousands.
These are always near the top of our stats summary on the home page, but not really relevant for us.

This will get overwritten by updaters, but it's an easy change when you update.

This is in the vsadmin/inc/incadmin.asp file. find the line below
sSQL="SELECT "&IIfVs(mysqlserver<>TRUE,"TOP 10 ")&"cartProdName, SUM(cartQuantity) AS numbought, SUM(cartProdPrice*cartQuantity) AS totalvalue FROM cart INNER JOIN orders ON cart.cartOrderID=orders.ordID WHERE cartDateAdded>=" & vsusdate(dbdate)&" AND cartCompleted=1 AND ordStatus>=3 GROUP BY cartProdName ORDER BY SUM(cartQuantity) DESC, SUM(cartProdPrice*cartQuantity) DESC"&IIfVs(mysqlserver=TRUE," LIMIT 0,10")


change that to this instead (area in red is where the change was made)
sSQL="SELECT "&IIfVs(mysqlserver<>TRUE,"TOP 10 ")&"cartProdName, SUM(cartQuantity) AS numbought, SUM(cartProdPrice*cartQuantity) AS totalvalue FROM cart INNER JOIN orders ON cart.cartOrderID=orders.ordID WHERE cartDateAdded>=" & vsusdate(dbdate)&" AND cartCompleted=1 AND ordStatus>=3 GROUP BY cartProdName ORDER BY SUM(cartProdPrice*cartQuantity) DESC, SUM(cartQuantity) DESC"&IIfVs(mysqlserver=TRUE," LIMIT 0,10")


If there is interest, I will post this up for .php - EDIT - php version below.

Enjoy,
David

Edited by - dbdave on 02/13/2019 22:21:12

midvalleydrifter001
Ecommerce Template Expert

USA
933 Posts

Posted - 02/10/2019 :  10:33:58  
I would be interested in the PHP version

Thanks

Patrick

dbdave
ECT Moderator

USA
10406 Posts

Posted - 02/11/2019 :  18:18:55  
Hi Patrick, it's actually a simple edit there as well. I have tested this to work for the .php version.

In your admin (vsadmin or secondary folder is used) it's the incadmin.php file you want (in the inc folder) and the line you want is a very similar select statement to the .asp version.

find the line below
$sSQL="SELECT cartProdName, SUM(cartQuantity) AS numbought, SUM(cartProdPrice*cartQuantity) AS totalvalue FROM cart INNER JOIN orders ON cart.cartOrderID=orders.ordID WHERE cartDateAdded>='".$dbdate."' AND cartCompleted=1 AND ordStatus>=3 GROUP BY cartProdName ORDER BY numbought DESC, totalvalue DESC LIMIT 0,10";


change that to this instead (area in red is where the change was made)
$sSQL="SELECT cartProdName, SUM(cartQuantity) AS numbought, SUM(cartProdPrice*cartQuantity) AS totalvalue FROM cart INNER JOIN orders ON cart.cartOrderID=orders.ordID WHERE cartDateAdded>='".$dbdate."' AND cartCompleted=1 AND ordStatus>=3 GROUP BY cartProdName ORDER BY totalvalue DESC, numbought DESC LIMIT 0,10";


Basically we are just reversing the totalvalue and numbought in both versions.

Let me know how you like it.
I might work up some additional features. I think it would be nice to hover over the total for the year and get a percentage increase (or decrease) amount,
much like you can hover over the number of orders there to get an average per order total. The same with month over month. To me, I want to see the percentage. It's nice to see the actual numbers,
but a percentage gain or loss is a better way to track progress.

Edited by - dbdave on 02/11/2019 18:20:09

midvalleydrifter001
Ecommerce Template Expert

USA
933 Posts

Posted - 02/11/2019 :  19:46:54  
I like it and yes the percentage feature would be very helpful.

Thanks

Patrick

dbdave
ECT Moderator

USA
10406 Posts

Posted - 02/11/2019 :  22:06:22  
This new additional feature is now working for .php and .asp
This feature will show you your percentage increase in sales on your admin home page stats summary.
Keep in mind that if you do not have sales for one of the time periods then you will just see a message that not enough data exists to make a calculation. (found this and fixed after "divide by zero" error occured )

The modification is in the same file - vsadmin/inc/incadmin/asp/.php (or yoursecretfolder/inc/incadmin/asp/.php if using a secondary admin)

Here is what you will see. This is a title tag that you can hover over the time period and get the info. Much like the existing title tag for the avearge $ per sale you get when you hover over the number of orders there.

IMAGE


We have been using this for over a week on my busy live ect website and I absolutely love it.
Perhaps ect will consider making it a native feature

Keep in mind this is a mod and will need to be redone when updating your site. Althought I think this is a file that not too often changed, so use a file comparison program when updating to check for changes and easily merge these changes to the new updates.

Always make a backup copy of files before modifying them.

:::PHP VERSION:::

STEP ONE
Around line 225 or so, look for the following block of code

$sincedate = date('l jS F', strtotime('-30 days'));
$sinceweekdate = date('l jS F', strtotime('-7 days'));
$dbdate = date('Y-m-d H:i:s', strtotime('-30 days'));
$dbweekdate = date('Y-m-d H:i:s', strtotime('-7 days'));
$thismonth=date('M');
$lastmonth = date('M', strtotime('first day of last month'));
$lastyear = date('M Y', strtotime('-1 year'));
$lastlastyear = date('M y', strtotime('-2 year'));
// echo $sincedate.' '.$dbdate;
?>
and add a new chunk of code there so it looks like the following - (new code shown in red)

$sincedate = date('l jS F', strtotime('-30 days'));
$sinceweekdate = date('l jS F', strtotime('-7 days'));
$dbdate = date('Y-m-d H:i:s', strtotime('-30 days'));
$dbweekdate = date('Y-m-d H:i:s', strtotime('-7 days'));
$thismonth=date('M');
$lastmonth = date('M', strtotime('first day of last month'));
$lastyear = date('M Y', strtotime('-1 year'));
$lastlastyear = date('M y', strtotime('-2 year'));
// echo $sincedate.' '.$dbdate;
if ($thismonthtotal[0] > 0 and $thismonthtotal[1] > 0) {
if ($thismonthtotal[0] > $thismonthtotal[1]) { $currmonthpct = 'Increase of '. (round($thismonthtotal[0]/$thismonthtotal[1]*100-100,2)).'%';
}else{ $currmonthpct = 'Decrease of '. (round(100-$thismonthtotal[0]/$thismonthtotal[1]*100,2)) .'%';
} }else{ $currmonthpct = 'Not enough Data to make calculation'; }
if ($lastmonthtotal[0] > 0 and $lastmonthtotal[1] > 0) {
if ($lastmonthtotal[0] > $lastmonthtotal[1]) { $lastmonthpct = 'Increase of '. (round($lastmonthtotal[0]/$lastmonthtotal[1]*100-100,2)).'%';
}else{ $lastmonthpct = 'Decrease of '. (round(100-$lastmonthtotal[0]/$lastmonthtotal[1]*100,2)) .'%';
} }else{ $lastmonthpct = 'Not enough Data to make calculation'; }
if ($yeartotal[0] > 0 and $yeartotal[1] > 0) {
if ($yeartotal[0] > $yeartotal[1]) { $thisyrpct = 'Increase of '. (round($yeartotal[0]/$yeartotal[1]*100-100,2)).'%';
}else{ $thisyrpct = 'Decrease of '. (round(100-$yeartotal[0]/$yeartotal[1]*100,2)) .'%';
} }else{ $thisyrpct = 'Not enough Data to make calculation'; }
if ($last12total[0] > 0 and $last12total[1] > 0) {
if ($last12total[0] > $last12total[1]) { $lastyrpct = 'Increase of '. (round($last12total[0]/$last12total[1]*100-100,2)).'%';
}else{ $lastyrpct = 'Decrease of '. (round(100-$last12total[0]/$last12total[1]*100,2)) .'%';
} }else{ $lastyrpct = 'Not enough Data to make calculation'; }

?>


STEP TWO Find / Replace 4 lines as shown below
FIND REPLACE 1 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><?php print $thismonth?></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="<?php print $thismonth?> vs <?php print $thismonth?> of last year - <?php print $currmonthpct?>"><?php print $thismonth?></div></td>

FIND REPLACE 2 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><?php print $lastmonth?></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="<?php print $lastmonth?> vs <?php print $lastmonth?> of last year - <?php print $lastmonthpct?>"><?php print $lastmonth?></div></td>

FIND REPLACE 3 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="January 1 - Now"><?php print "Jan 1 »"?></div></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="January 1 to today - <?php print $thisyrpct?>"><?php print "Jan 1 »"?></div></td>

FIND REPLACE 4 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="Last 12 Months"><?php print '12 Mo.'?></div></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="Last 12 Months - <?php print $lastyrpct?>"><?php print '12 Mo.'?></div></td>


That's it - Upload the file and give it a test drive.

:::ASP VERSION:::

STEP ONE
Around line 230 or so, look for the following block of code

lmdate=date()-day(date())
sincedate = date()-30
' sinceweekdate = date('l jS F', strtotime('-7 days'));
dbdate = date()-30
dbweekdate = date()-7
thismonth=monthname(month(date()),TRUE)
lastmonth=monthname(month(lmdate),TRUE)
lastyear=monthname(month(lmdate),TRUE)&" "&(year(date())-1)
%>
and add a new chunk of code there so it looks like the following - (new code shown in red)

lmdate=date()-day(date())
sincedate = date()-30
' sinceweekdate = date('l jS F', strtotime('-7 days'));
dbdate = date()-30
dbweekdate = date()-7
thismonth=monthname(month(date()),TRUE)
lastmonth=monthname(month(lmdate),TRUE)
lastyear=monthname(month(lmdate),TRUE)&" "&(year(date())-1)
dim currmonthpct, lastmonthpct, lastyrpct, thisyrpct
if thismonthtotal(0) > 0 and thismonthtotal(1) > 0 then
if thismonthtotal(0) > thismonthtotal(1) then
currmonthpct = "Increase of "& (Round(thismonthtotal(0)/thismonthtotal(1)*100-100,2))&"%"
else
currmonthpct = "Decrease of "& (Round(100-thismonthtotal(0)/thismonthtotal(1)*100,2)) &"%"
end if
else
currmonthpct = "Not enough Data to make calculation"
end if
if lastmonthtotal(0) > 0 and lastmonthtotal(1) > 0 then
if lastmonthtotal(0) > lastmonthtotal(1) then
lastmonthpct = "increase of "& (Round(lastmonthtotal(0)/lastmonthtotal(1)*100-100,2))&"%"
else
lastmonthpct = "decrease of "& (Round(100-lastmonthtotal(0)/lastmonthtotal(1)*100,2)) &"%"
end if
else
lastmonthpct = "Not enough Data to make calculation"
end if
if yeartotal(0) > 0 and yeartotal(1) > 0 then
if yeartotal(0) > yeartotal(1) then
thisyrpct = "increase of "& (Round(yeartotal(0)/yeartotal(1)*100-100,2))&"%"
else
thisyrpct = "decrease of "& (Round(100-yeartotal(0)/yeartotal(1)*100,2)) &"%"
end if
else
thisyrpct = "Not enough Data to make calculation"
end if
if last12total(0) > 0 and last12total(1) > 0 then
if last12total(0) > last12total(1) then
lastyrpct = "increase of "& (Round(last12total(0)/last12total(1)*100-100,2))&"%"
else
lastyrpct = "decrease of "& (Round(100-last12total(0)/last12total(1)*100,2)) &"%"
end if
else
lastyrpct = "Not enough Data to make calculation"
end if

%>


STEP TWO Find / Replace 4 lines as shown below
FIND REPLACE 1 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><%=thismonth%></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="<%=thismonth%> vs <%=thismonth%> of last year - <%=currmonthpct%>"><%=thismonth%></div></td>

FIND REPLACE 2 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><%=lastmonth%></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="<%=lastmonth%> vs <%=lastmonth%> of last year - <%=lastmonthpct%>"><%=lastmonth%></div></td>

FIND REPLACE 3 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="January 1 - Now"><%="Jan 1 »"%></div></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="January 1 through today - <%=thisyrpct%>"><%="Jan 1 »"%></div></td>

FIND REPLACE 4 OF 4
Find this line
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="Last 12 Months"><%="12 Mo."%></div></td>

replace with this
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="Last 12 Months - <%=lastyrpct%>"><%="12 Mo."%></div></td>


That's it - Upload the file and give it a test drive.

Edited by - dbdave on 05/06/2023 08:03:49

midvalleydrifter001
Ecommerce Template Expert

USA
933 Posts

Posted - 02/14/2019 :  16:48:54  
Works great.

How would I break down the percentage (+/-) to the hundredth rather that rounding as you have it now?

Patrick

dbdave
ECT Moderator

USA
10406 Posts

Posted - 02/14/2019 :  17:14:37  
That's awesome Patrick. I think it's quite powerful to see these numbers at a quick glance.
I will look at the rounding. I think with .php the default is two places unless specified otherwise.
I think it's an easy change, but I just finished polishing touches on the .asp version so I am going to post that up, and then I will take a look at the rounding.

dbdave
ECT Moderator

USA
10406 Posts

Posted - 02/14/2019 :  18:14:32  
Hi Patrick, in looking at the rounding, I discovered n error in the way the calculations were being made, so I revised the code above, and you should fix yours.

The "2" there in red is the decimal places. Change those to "3" (8 instances there) and that will do it.
credit this page for the rounding info - right from the source http://php.net/manual/en/function.round.php


if ($thismonthtotal[0] > 0 and $thismonthtotal[1] > 0) {
if ($thismonthtotal[0] > $thismonthtotal[1]) { $currmonthpct = 'Increase of '. (round($thismonthtotal[0]/$thismonthtotal[1]*100-100,2)).'%';
}else{ $currmonthpct = 'Decrease of '. (round(100-$thismonthtotal[0]/$thismonthtotal[1]*100,2)) .'%';
} }else{ $currmonthpct = 'Not enough Data to make calculation'; }
if ($lastmonthtotal[0] > 0 and $lastmonthtotal[1] > 0) {
if ($lastmonthtotal[0] > $lastmonthtotal[1]) { $lastmonthpct = 'Increase of '. (round($lastmonthtotal[0]/$lastmonthtotal[1]*100-100,2)).'%';
}else{ $lastmonthpct = 'Decrease of '. (round(100-$lastmonthtotal[0]/$lastmonthtotal[1]*100,2)) .'%';
} }else{ $lastmonthpct = 'Not enough Data to make calculation'; }
if ($yeartotal[0] > 0 and $yeartotal[1] > 0) {
if ($yeartotal[0] > $yeartotal[1]) { $thisyrpct = 'Increase of '. (round($yeartotal[0]/$yeartotal[1]*100-100,2)).'%';
}else{ $thisyrpct = 'Decrease of '. (round(100-$yeartotal[0]/$yeartotal[1]*100,2)) .'%';
} }else{ $thisyrpct = 'Not enough Data to make calculation'; }
if ($last12total[0] > 0 and $last12total[1] > 0) {
if ($last12total[0] > $last12total[1]) { $lastyrpct = 'Increase of '. (round($last12total[0]/$last12total[1]*100-100,2)).'%';
}else{ $lastyrpct = 'Decrease of '. (round(100-$last12total[0]/$last12total[1]*100,2)) .'%';
} }else{ $lastyrpct = 'Not enough Data to make calculation'; }

Edited by - dbdave on 02/14/2019 18:20:45

midvalleydrifter001
Ecommerce Template Expert

USA
933 Posts

Posted - 02/14/2019 :  18:38:47  
PERFECT !!

Nice job. I really like it.

Thanks for taking the time to do this.

Patrick

midvalleydrifter001
Ecommerce Template Expert

USA
933 Posts

Posted - 02/15/2019 :  12:31:37  
I totally agree with metrics. Very important data to utilize.

Thanks for sharing your knowledge.

I too have learned so much from this forum and value everything and everybody who provides advice.

I looked at the justgage.com website and their js files.

Can their info be linked to ECT or is that a manual thing to input?

Not quite sure how to implement that on my site.

Edited by - midvalleydrifter001 on 02/15/2019 12:36:17

PieMan
Advanced Member

United Kingdom
272 Posts

Pre-sales questions only
(More Details...)

Posted - 03/18/2019 :  05:02:37  
Hi Dave,

the percentage increase/decrease is a nice simple mod that gives extra info, thank you.

Maybe it's something that Vince and Andy can incorporate in an updater in the future.

Regards

Mike

Using ECT since 2003.

John M
Advanced Member

459 Posts

Pre-sales questions only
(More Details...)

Posted - 04/18/2019 :  10:03:22  
Very cool... I made some changes for a cleaner look with coloured arrows showing all the time.

[red]

if ($thismonthtotal[0] > 0 and $thismonthtotal[1] > 0) {
if ($thismonthtotal[0] > $thismonthtotal[1]) { $currmonthpct = '#8593; ' . (round($thismonthtotal[0]/$thismonthtotal[1]*100-100,0)).'%'; $color="green";
}else{ $currmonthpct = '#8595; ' . (round(100-$thismonthtotal[0]/$thismonthtotal[1]*100,0)) .'%'; $color="red";
} }else{ $currmonthpct = '#8594; '; $color="orange";}
if ($lastmonthtotal[0] > 0 and $lastmonthtotal[1] > 0) {
if ($lastmonthtotal[0] > $lastmonthtotal[1]) { $lastmonthpct = '#8593; '. (round($lastmonthtotal[0]/$lastmonthtotal[1]*100-100,0)).'%'; $color="green";
}else{ $lastmonthpct = '#8595; '. (round(100-$lastmonthtotal[0]/$lastmonthtotal[1]*100,0)) .'%'; $color="red";
} }else{ $lastmonthpct = '#8594; '; $color="orange";}
if ($yeartotal[0] > 0 and $yeartotal[1] > 0) {
if ($yeartotal[0] > $yeartotal[1]) { $thisyrpct = '#8593; '. (round($yeartotal[0]/$yeartotal[1]*100-100,0)).'%'; $color="green";
}else{ $thisyrpct = '#8595; '. (round(100-$yeartotal[0]/$yeartotal[1]*100,0)) .'%'; $color="red";
} }else{ $thisyrpct = '#8594; '; $color="orange";}
if ($last12total[0] > 0 and $last12total[1] > 0) {
if ($last12total[0] > $last12total[1]) { $lastyrpct = '#8593; '. (round($last12total[0]/$last12total[1]*100-100,0)).'%'; $color="green";
}else{ $lastyrpct = '#8595; '. (round(100-$last12total[0]/$last12total[1]*100,0)) .'%'; $color="red";
} }else{ $lastyrpct = '#8594; '; $color="orange";}
// echo $sincedate.' '.$dbdate;
?>


<div class="one_third">
<h3 class="round_top">Order Stats<br><span style="font-weight:normal;font-size:10px">This month, last month, last year</span></h3>
<table class="quickstats">
<tr><th> </th><th> </th><th style="text-align:right;">No</th><th style="text-align:right;">Value</th></tr>
<tr>
<td style="text-align:right;vertical-align:middle;" rowspan="2"><div title="<?php print $currmonthpct?>"><?php print $thismonth?></div></td>
<td style="text-align:right;font-size:0.9em;"><span style="color:<?php print $color ?>"><?php print $currmonthpct?></span> This Year</td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($thismonthorders[0]==0?0:$thismonthtotal[0]/$thismonthorders[0]);?>"><?php print $thismonthorders[0] . '</td><td style="text-align:right;font-size:0.9em">' . FormatEuroCurrency($thismonthtotal[0]);?></td>
</tr>
<tr>
<td style="text-align:right;font-size:0.9em;color:#FF6060">Last Year</td>
<td style="text-align:right;font-size:0.9em;color:#FF6060" title="<?php print FormatEuroCurrency($thismonthorders[1]==0?0:$thismonthtotal[1]/$thismonthorders[1]);?>"><?php print $thismonthorders[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($thismonthtotal[1]);?></td>
</tr>
<tr>
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="<?php print $lastmonthpct?>"><?php print $lastmonth?></div></td>
<td style="text-align:right;font-size:0.9em"><span style="color:<?php print $color ?>"><?php print $lastmonthpct?></span> This Year</td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($lastmonthorders[0]==0?0:$lastmonthtotal[0]/$lastmonthorders[0]);?>"><?php print $lastmonthorders[0] . '</td><td style="text-align:right;font-size:0.9em">' . FormatEuroCurrency($lastmonthtotal[0]);?></td>
</tr>
<tr>
<td style="text-align:right;font-size:0.9em;color:#FF6060">Last Year</td>
<td style="text-align:right;font-size:0.9em;color:#FF6060" title="<?php print FormatEuroCurrency($lastmonthorders[1]==0?0:$lastmonthtotal[1]/$lastmonthorders[1]);?>"><?php print $lastmonthorders[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($lastmonthtotal[1]);?></td>
</tr>
<tr>
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="<?php print $thisyrpct?>"><?php print "Jan 1 »"?></div></td>
<td style="text-align:right;font-size:0.9em"><span style="color:<?php print $color ?>"><?php print $thisyrpct?></span> This Year</td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($yearorders[0]==0?0:$yeartotal[0]/$yearorders[0]);?>"><?php print $yearorders[0] . '</td><td style="text-align:right;font-size:0.9em">' . FormatEuroCurrency($yeartotal[0]);?></td>
</tr>
<tr>
<td style="text-align:right;font-size:0.9em;color:#FF6060">Last Year</td>
<td style="text-align:right;font-size:0.9em;color:#FF6060" title="<?php print FormatEuroCurrency($yearorders[1]==0?0:$yeartotal[1]/$yearorders[1]);?>"><?php print $yearorders[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($yeartotal[1]);?></td>
</tr>
<tr>
<td style="text-align:right;vertical-align:middle" rowspan="2"><div title="Last 12 Months - <?php print $lastyrpct?>"><?php print '12 Mo.'?></div></td>
<td style="text-align:right;font-size:0.9em"><span style="color:<?php print $color ?>"><?php print $lastyrpct?></span> This Year</td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($last12[0]==0?0:$last12total[0]/$last12[0]);?>"><?php print $last12[0] . '</td><td style="text-align:right;font-size:0.9em">' . FormatEuroCurrency($last12total[0]);?></td>
</tr>
<tr>
<td style="text-align:right;font-size:0.9em;color:#FF6060">Last Year</td>
<td style="text-align:right;font-size:0.9em;color:#FF6060" title="<?php print FormatEuroCurrency($last12[1]==0?0:$last12total[1]/$last12[1]);?>"><?php print $last12[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($last12total[1]);?></td>
</tr>
<tr>
<td style="text-align:right;white-space:nowrap"><div title="All Time Sales"><?php print 'All Time'?></div></td>
<td style="font-size:0.9em"> </td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($alltime==0?0:$alltimetotal/$alltime);?>"><?php print $alltime . '</td><td style="text-align:right;font-size:0.9em">' . FormatCurrencyZeroDP($alltimetotal);?></td>
</tr>
</table>
</div>

[/red]

midvalleydrifter001
Ecommerce Template Expert

USA
933 Posts

Posted - 05/15/2019 :  19:00:04  
Hi John,

I have your mod applied but the GREEN increase and % is in RED.

Only the RED shows for both Decreases and Increases.

Any idea why this is happening?

Patrick

John M
Advanced Member

459 Posts

Pre-sales questions only
(More Details...)

Posted - 05/19/2019 :  21:30:36  
All of the arrow colours now work correctly.

Added stats for [blue]today, 7days, 15days and 30days[/blue]

Last year stats now show with a mouse hover over the time periods instead of using an extra line.
You can still show last year stats on a separate line by adding [blue]$displaylastyearstats=2;[/blue] to your includes file however they are a bit redundant and clutters things some what.

The calculations now display a percentage increase or decrease rather than a growth percentage, which makes the same calculation uniform across all scenarios even with Positive or Negative results and virtually all divide by zero issues are avoided.

John

Everything in red from LINE 162
// this month, last month and this month last year order totals

[red]if(@$dumpadminstats) print "Section 1 : " . (microtime_float()-$time_start)."<br />";
$thismonthorders=$thismonthtotal=$lastmonthorders=$lastmonthtotal=$yearorders=$yeartotal=[];

if(@$homeordersstatus!='') $ordersstatus='ordStatus IN ('.$homeordersstatus.')'; else $ordersstatus='ordStatus>=3';
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND YEAR(ordDate) = YEAR(CURRENT_DATE ) AND MONTH(ordDate) = MONTH(CURRENT_DATE)";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$thismonthorders[0]=$rs['totalorders'];$thismonthtotal[0]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND YEAR(ordDate) = YEAR(CURRENT_DATE - INTERVAL 12 MONTH) AND MONTH(ordDate) = MONTH(CURRENT_DATE - INTERVAL 12 MONTH)";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$thismonthorders[1]=$rs['totalorders'];$thismonthtotal[1]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE - INTERVAL 30 DAY)";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last30[0]=$rs['totalorders'];$last30total[0]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE - interval 1 year) - interval 30 day AND ordDate <= CURRENT_DATE - interval 1 year;";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last30[1]=$rs['totalorders'];$last30total[1]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE - INTERVAL 15 DAY)";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last15[0]=$rs['totalorders'];$last15total[0]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE - interval 1 year) - interval 15 day AND ordDate <= CURRENT_DATE - interval 1 year;";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last15[1]=$rs['totalorders'];$last15total[1]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE - INTERVAL 7 DAY)";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last7[0]=$rs['totalorders'];$last7total[0]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE - interval 1 year) - interval 7 day AND ordDate <= CURRENT_DATE - interval 1 year;";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last7[1]=$rs['totalorders'];$last7total[1]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE);";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$todayorders[0]=$rs['totalorders'];$todaytotal[0]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 2 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate >= (CURRENT_DATE - interval 1 year) AND ordDate <= (CURRENT_DATE + 1) - interval 1 year";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$todayorders[1]=$rs['totalorders'];$todaytotal[1]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 3 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND YEAR(ordDate) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH) AND MONTH(ordDate) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$lastmonthorders[0]=$rs['totalorders'];$lastmonthtotal[0]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 4 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND YEAR(ordDate) = YEAR(CURRENT_DATE - INTERVAL 13 MONTH) AND MONTH(ordDate) = MONTH(CURRENT_DATE - INTERVAL 13 MONTH)";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$lastmonthorders[1]=$rs['totalorders'];$lastmonthtotal[1]=$rs['totalvalue'];}
}
if(@$dumpadminstats) print "Section 5 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate BETWEEN '" . date("Y-01-01") . "' AND '" . date("Y-m-d",strtotime("+1 day")) . "'";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$yearorders[0]=$rs['totalorders'];$yeartotal[0]=$rs['totalvalue'];}
}
if(@$dumpadminstats) print "Section 6 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate BETWEEN '" . date("Y-01-01",strtotime("-1 year")) . "' AND '" . date("Y-m-d",strtotime("-1 year")) . "'";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$yearorders[1]=$rs['totalorders'];$yeartotal[1]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 7 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate BETWEEN '" . date("Y-m-d",strtotime("-1 year")) . "' AND '" . date("Y-m-d",strtotime("+1 day")) . "'";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last12[0]=$rs['totalorders'];$last12total[0]=$rs['totalvalue'];}
}

if(@$dumpadminstats) print "Section 8 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus." AND ordDate BETWEEN '" . date("Y-m-d",strtotime("-2 year")) . "' AND '" . date("Y-m-d",strtotime("-1 year")) . "'";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$last12[1]=$rs['totalorders'];$last12total[1]=$rs['totalvalue'];}
}
if(@$dumpadminstats) print "Section 9 : " . (microtime_float()-$time_start)."<br />";
$sSQL = " SELECT COUNT(*) AS totalorders, SUM(ordTotal-ordDiscount) AS totalvalue FROM orders WHERE ".$ordersstatus."";
$result=ect_query($sSQL) or ect_error();
if($rs=ect_fetch_assoc($result)){
if(!is_null($rs['totalorders'])){$alltime=$rs['totalorders'];$alltimetotal=$rs['totalvalue'];}
}
if(@$dumpadminstats) print "Section 10 : " . (microtime_float()-$time_start)."<br />";
// END this month, last month and this month last year order totals

$sincedate = date('l jS F', strtotime('-30 days'));
$sinceweekdate = date('l jS F', strtotime('-7 days'));
$dbdate = date('Y-m-d H:i:s', strtotime('-30 days'));
$dbweekdate = date('Y-m-d H:i:s', strtotime('-7 days'));
$thismonth=date('M');
$last30days='30 Days';
$last15days='15 Days';
$last7days='7 Days';
$today='Today';
$lastmonth = date('M', strtotime('first day of last month'));
$lastyear = date('M Y', strtotime('-1 year'));
$lastlastyear = date('M y', strtotime('-2 year'));

if ($displaylastyearstats==1)
{
$displaythisyear='';
$displaylastyear='';
}
else
{
$displaythisyear=' This Year';
$displaylastyear=' Last Year';
}


function updatethismonth()
{
global $thismonthtotal,$thismonthorders,$currmonthpct,$currmonthorderspct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($thismonthtotal[0] > 0 and $thismonthtotal[1] > 0)
{
if ($thismonthtotal[0] > $thismonthtotal[1])
{
$currmonthpct = '#8593; ' . (round(($thismonthtotal[0]-$thismonthtotal[1])/$thismonthtotal[1]*100,0)).'%'; $colortotal="green";
}
else
{
$currmonthpct = '#8595; ' . (round(($thismonthtotal[0]-$thismonthtotal[1])/$thismonthtotal[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$currmonthpct = '#8594; '; $colortotal="orange";
}
if ($thismonthorders[0] > 0 and $thismonthorders[1] > 0)
{
if ($thismonthorders[0] > $thismonthorders[1])
{
$currmonthorderspct = '#8593; ' . (round(($thismonthorders[0]-$thismonthorders[1])/$thismonthorders[1]*100,0)).'%'; $colororders="green";
}
else
{
$currmonthorderspct = '#8595; ' . (round(($thismonthorders[0]-$thismonthorders[1])/$thismonthorders[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$currmonthorderspct = '#8594; '; $colororders="orange";
}
}
function updatelastmonth()
{
global $lastmonthtotal,$lastmonthorders,$lastmonthpct,$lastmonthorderspct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($lastmonthtotal[0] > 0 and $lastmonthtotal[1] > 0)
{
if ($lastmonthtotal[0] > $lastmonthtotal[1])
{
$lastmonthpct = '#8593; ' . (round(($lastmonthtotal[0]-$lastmonthtotal[1])/$lastmonthtotal[1]*100,0)).'%'; $colortotal="green";
}
else
{
$lastmonthpct = '#8595; ' . (round(($lastmonthtotal[0]-$lastmonthtotal[1])/$lastmonthtotal[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$lastmonthpct = '#8594; '; $colortotal="orange";
}
if ($lastmonthorders[0] > 0 and $lastmonthorders[1] > 0)
{
if ($lastmonthorders[0] > $lastmonthorders[1])
{
$lastmonthorderspct = '#8593; ' . (round(($lastmonthorders[0]-$lastmonthorders[1])/$lastmonthorders[1]*100,0)).'%'; $colororders="green";
}
else
{
$lastmonthorderspct = '#8595; ' . (round(($lastmonthorders[0]-$lastmonthorders[1])/$lastmonthorders[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$lastmonthorderspct = '#8594; '; $colororders="orange";
}
}
function updatethisyear(){
global $yeartotal,$yearorders,$thisyrpct,$thisyrorderpct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($yeartotal[0] > 0 and $yeartotal[1] > 0)
{
if ($yeartotal[0] > $yeartotal[1])
{
$thisyrpct = '#8593; '. (round(($yeartotal[0]-$yeartotal[1])/$yeartotal[1]*100,0)).'%'; $colortotal="green";
}
else
{
$thisyrpct = '#8595; '. (round(($yeartotal[0]-$yeartotal[1])/$yeartotal[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$thisyrpct = '#8594; '; $colortotal="orange";
}
if ($yearorders[0] > 0 and $yearorders[1] > 0)
{
if ($yearorders[0] > $yearorders[1])
{
$thisyrorderpct = '#8593; ' . (round(($yearorders[0]-$yearorders[1])/$yearorders[1]*100,0)).'%'; $colororders="green";
}
else
{
$thisyrorderpct = '#8595; ' . (round(($yearorders[0]-$yearorders[1])/$yearorders[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$thisyrorderpct = '#8594; '; $colororders="orange";
}
}
function updatelast12()
{
global $last12total,$last12,$lastyrpct,$lastyrorderpct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($last12total[0] > 0 and $last12total[1] > 0)
{
if ($last12total[0] > $last12total[1])
{
$lastyrpct = '#8593; ' . (round(($last12total[0]-$last12total[1])/$last12total[1]*100,0)).'%'; $colortotal="green";
}
else
{
$lastyrpct = '#8595; ' . (round(($last12total[0]-$last12total[1])/$last12total[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$lastyrpct = '#8594; '; $colortotal="orange";
}
if ($last12[0] > 0 and $last12[1] > 0)
{
if ($last12[0] > $last12[1])
{
$lastyrorderpct = '#8593; ' . (round(($last12[0]-$last12[1])/$last12[1]*100,0)).'%'; $colororders="green";
}
else
{
$lastyrorderpct = '#8595; ' . (round(($last12[0]-$last12[1])/$last12[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$lastyrorderpct = '#8594; '; $colororders="orange";
}
}
function updatelast30()
{
global $last30total,$last30,$last30pct,$last30orderpct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($last30total[0] > 0 and $last30total[1] > 0)
{
if ($last30total[0] > $last30total[1])
{
$last30pct = '#8593; '. (round(($last30total[0]-$last30total[1])/$last30total[1]*100,0)).'%'; $colortotal="green";
}
else
{
$last30pct = '#8595; '. (round(($last30total[0]-$last30total[1])/$last30total[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$last30pct = '#8594; '; $colortotal="orange";
}
if ($last30[0] > 0 and $last30[1] > 0)
{
if ($last30[0] > $last30[1])
{
$last30orderpct = '#8593; '. (round(($last30[0]-$last30[1])/$last30[1]*100,0)).'%'; $colororders="green";
}
else
{
$last30orderpct = '#8595; '. (round(($last30[0]-$last30[1])/$last30[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$last30orderpct = '#8594; '; $colororders="orange";
}
}
function updatelast15(){
global $last15total,$last15,$last15pct,$last15orderpct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($last15total[0] > 0 and $last15total[1] > 0)
{
if ($last15total[0] > $last15total[1])
{
$last15pct = '#8593; '. (round(($last15total[0]-$last15total[1])/$last15total[1]*100,0)).'%'; $colortotal="green";
}
else
{
$last15pct = '#8595; '. (round(($last15total[0]-$last15total[1])/$last15total[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$last15pct = '#8594; '; $colortotal="orange";
}
if ($last15[0] > 0 and $last15[1] > 0)
{
if ($last15[0] > $last15[1])
{
$last15orderpct = '#8593; '. (round(($last15[0]-$last15[1])/$last15[1]*100,0)).'%'; $colororders="green";
}
else
{
$last15orderpct = '#8595; '. (round(($last15[0]-$last15[1])/$last15[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$last15orderpct = '#8594; '; $colororders="orange";
}
}
function updatelast7(){
global $last7total,$last7,$last7pct,$last7orderpct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($last7total[0] > 0 and $last7total[1] > 0)
{
if ($last7total[0] > $last7total[1])
{
$last7pct = '#8593; '. (round(($last7total[0]-$last7total[1])/$last7total[1]*100,0)).'%'; $colortotal="green";
}
else
{
$last7pct = '#8595; '. (round(($last7total[0]-$last7total[1])/$last7total[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$last7pct = '#8594; '; $colortotal="orange";
}
if ($last7[0] > 0 and $last7[1] > 0)
{
if ($last7[0] > $last7[1])
{
$last7orderpct = '#8593; '. (round(($last7[0]-$last7[1])/$last7[1]*100,0)).'%'; $colororders="green";
}
else
{
$last7orderpct = '#8595; '. (round(($last7[0]-$last7[1])/$last7[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$last7pct = '#8594; '; $colororders="orange";
}}
function updatetoday(){
global $todaytotal,$todayorders,$todaypct,$todayorderpct,$colortotal,$colororders;
$colortotal=''; $colororders='';

if ($todaytotal[0] > 0 and $todaytotal[1] > 0)
{
if ($todaytotal[0] > $todaytotal[1])
{
$todaypct = '#8593; '. (round(($todaytotal[0]-$todaytotal[1])/$todaytotal[1]*100,0)).'%'; $colortotal="green";
}
else
{
$todaypct = '#8595; '. (round(($todaytotal[0]-$todaytotal[1])/$todaytotal[1]*100,0)) .'%'; $colortotal="red";
}
}
else
{
$todaypct = '#8594; '; $colortotal="orange";
}

if ($todayorders[0] > 0 and $todayorders[1] > 0)
{
if ($todayorders[0] > $todayorders[1])
{
$todayorderpct = '#8593; '. (round(($todayorders[0]-$todayorders[1])/$todayorders[1]*100,0)).'%'; $colororders="green";
}
else
{
$todayorderpct = '#8595; ' . (round(($todayorders[0]-$todayorders[1])/$todayorders[1]*100,0)) .'%'; $colororders="red";
}
}
else
{
$todayorderpct = '#8594; '; $colororders="orange";
}
}

// echo $sincedate.' '.$dbdate;
?>


<div class="one_third">
<h3 class="round_top">Order Stats<br><span style="font-weight:normal;font-size:10px">This month, last month, last year</span></h3>
<table class="quickstats">
<tr><th> </th><th> </th><th style="text-align:right;">No</th><th style="text-align:right;">Value</th></tr>

<?php updatetoday();
$lastyearstats='Last Year: ' . $todayorders[1] . ' - ' . FormatEuroCurrency($todaytotal[1]);
?>

<tr>
<td style="text-align:right;vertical-align:middle;" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print $today ?></div></td>
<td style="text-align:right;font-size:0.9em;"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($todayorders[0]==0?0:$todaytotal[0]/$todayorders[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $todayorderpct ?></span>    <?php print $todayorders[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $todaypct . '</span>   ' . FormatEuroCurrency($todaytotal[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($todayorders[1]==0?0:$todaytotal[1]/$todayorders[1]) . '">' . $todayorders[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($todaytotal[1]) . '</td></tr>';
}
?>

<?php updatelast7();
$lastyearstats='Last Year: ' . $last7[1] . ' - ' . FormatEuroCurrency($last7total[1]);
?>

<tr>
<td style="text-align:right;vertical-align:middle;" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print $last7days ?></div></td>
<td style="text-align:right;font-size:0.9em;"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($last7[0]==0?0:$last7total[0]/$last7[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $last7orderpct ?></span>    <?php print $last7[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $last7pct . '</span>   ' . FormatEuroCurrency($last7total[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($last7[1]==0?0:$last7total[1]/$last7[1]) . '">' . $last7[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($last7total[1]) . '</td></tr>';
}
?>


<?php updatelast15();
$lastyearstats='Last Year: ' . $last15[1] . ' - ' . FormatEuroCurrency($last15total[1]);
?>

<tr>
<td style="text-align:right;vertical-align:middle;" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print $last15days ?></div></td>
<td style="text-align:right;font-size:0.9em;"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($last15[0]==0?0:$last15total[0]/$last15[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $last15orderpct ?></span>    <?php print $last15[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $last15pct . '</span>   ' . FormatEuroCurrency($last15total[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($last15[1]==0?0:$last15total[1]/$last15[1]) . '">' . $last15[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($last15total[1]) . '</td></tr>';
}
?>

<?php updatelast30();
$lastyearstats='Last Year: ' . $last30[1] . ' - ' . FormatEuroCurrency($last30total[1]);
?>

<tr>
<td style="text-align:right;vertical-align:middle;" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print $last30days ?></div></td>
<td style="text-align:right;font-size:0.9em;"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($last30[0]==0?0:$last30total[0]/$last30[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $last30orderpct ?></span>    <?php print $last30[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $last30pct . '</span>   ' . FormatEuroCurrency($last30total[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($last30[1]==0?0:$last30total[1]/$last30[1]) . '">' . $last30[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($last30total[1]) . '</td></tr>';
}
?>

<?php updatethismonth();
$lastyearstats='Last Year: ' . $thismonthorders[1] . ' - ' . FormatEuroCurrency($thismonthtotal[1]);
?>

<tr>
<td style="text-align:right;vertical-align:middle;" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print $thismonth?></div></td>
<td style="text-align:right;font-size:0.9em;"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($thismonthorders[0]==0?0:$thismonthtotal[0]/$thismonthorders[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $currmonthorderspct ?></span>    <?php print $thismonthorders[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $currmonthpct . '</span>   ' . FormatEuroCurrency($thismonthtotal[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($thismonthorders[1]==0?0:$thismonthtotal[1]/$thismonthorders[1]) . '">' . $thismonthorders[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($thismonthtotal[1]) . '</td></tr>';
}
?>

<?php updatelastmonth();
$lastyearstats='Last Year: ' . $lastmonthorders[1] . ' - ' . FormatEuroCurrency($lastmonthtotal[1]);

?>

<tr>
<td style="text-align:right;vertical-align:middle" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print $lastmonth?></div></td>
<td style="text-align:right;font-size:0.9em"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($lastmonthorders[0]==0?0:$lastmonthtotal[0]/$lastmonthorders[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $lastmonthorderspct ?></span>   <?php print $lastmonthorders[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $lastmonthpct . '</span>   ' . FormatEuroCurrency($lastmonthtotal[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($lastmonthorders[1]==0?0:$lastmonthtotal[1]/$lastmonthorders[1]) . '">' . $lastmonthorders[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($lastmonthtotal[1]) . '</td></tr>';
}
?>

<?php updatethisyear();
$lastyearstats='Last Year: ' . $yearorders[1] . ' - ' . FormatEuroCurrency($yeartotal[1]);
?>

<tr>
<td style="text-align:right;vertical-align:middle" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print "This Year"?></div></td>
<td style="text-align:right;font-size:0.9em"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($yearorders[0]==0?0:$yeartotal[0]/$yearorders[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $thisyrorderpct ?></span>   <?php print $yearorders[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $thisyrpct . '</span>   ' . FormatEuroCurrency($yeartotal[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($yearorders[1]==0?0:$yeartotal[1]/$yearorders[1]) . '">' . $yearorders[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($yeartotal[1]) . '</td></tr>';
}
?>

<?php updatelast12();
$lastyearstats='Last Year: ' . $last12[1] . ' - ' . FormatEuroCurrency($last12total[1]);
?>

<tr>
<td style="text-align:right;vertical-align:middle;" rowspan="<?php (print $displaylastyearstats);?>"><div title="<?php print $lastyearstats?>"><?php print '12 Mo.' ?></div></td>
<td style="text-align:right;font-size:0.9em"><?php print $displaythisyear?></td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($last12[0]==0?0:$last12total[0]/$last12[0]);?>"><span style="color:<?php print $colororders ?>"><?php print $lastyrorderpct ?></span>   <?php print $last12[0] . '</td><td style="text-align:right;font-size:0.9em"><span style="color:' . $colortotal . '">' . $lastyrpct . '</span>   ' . FormatEuroCurrency($last12total[0]);?></td>
</tr>

<?php
if ($displaylastyearstats==2)
{
print '<tr><td style="text-align:right;font-size:0.9em;color:#FF6060">' . $displaylastyear . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060" title="' . FormatEuroCurrency($last12[1]==0?0:$last12total[1]/$last12[1]) . '">' . $last12[1] . '</td><td style="text-align:right;font-size:0.9em;color:#FF6060">' . FormatEuroCurrency($last12total[1]) . '</td></tr>';
}
?>

<tr>
<td style="text-align:right;white-space:nowrap"><div title="All Time Sales"><?php print 'All Time'?></div></td>
<td style="font-size:0.9em"> </td>
<td style="text-align:right;font-size:0.9em" title="<?php print FormatEuroCurrency($alltime==0?0:$alltimetotal/$alltime);?>"><?php print $alltime . '</td><td style="text-align:right;font-size:0.9em">' . FormatCurrencyZeroDP($alltimetotal);?></td>
</tr>
</table>
</div>[/red]

<div class="one_third">
<h3 class="round_top">Top Sellers: Last 30 days

Edited by - John M on 05/27/2019 08:38:41

midvalleydrifter001
Ecommerce Template Expert

USA
933 Posts

Posted - 05/26/2019 :  15:14:37  
Thanks John for the update. Love all the details.

Only thing I had to tweak was adding the & sign in front of all the arrow sections = &#8595; etc to get the arrows to show. Example: $last7orderpct = '&#8593;

Also had to add & raquo; (without the space) to get the » symbol to show after the Jan 1 » stats

Patrick



Edited by - midvalleydrifter001 on 05/26/2019 15:30:39

John M
Advanced Member

459 Posts

Pre-sales questions only
(More Details...)

Posted - 05/27/2019 :  08:42:05  
Hi Patrick,

I tried to update however it seems to be the forum that is stripping out the [red]&[/red] signs???

Yes the details are great... The [blue]Today 7Day 15Day 30Day[/blue] running totals are so informative and to see the percentage increase or decrease at a glance... I really don't see how we managed in the past without them.

John

Edited by - John M on 05/27/2019 08:54:41

John M
Advanced Member

459 Posts

Pre-sales questions only
(More Details...)

Posted - 07/01/2019 :  08:23:35  
Hi Mike,

Here is the latest code below which should take care of the issues.

When starting out a new site with little data from the previous year it should now show up as green infinity when the previous year data is zero.

Note. The percentages are growth rate percentages so when your sales double this is a 100% growth rate...

I have included the whole of the incadmin.php this time so you can simply save as a new file and move into place instead of making edits... Hopefully this is easier but let me know.

Cheers,

John

[code]

<?php
//This code is copyright (c) Internet Business Solutions SL, all rights reserved.
//The contents of this file are protected under law as the intellectual property of Internet
//Business Solutions SL. Any use, reproduction, disclosure or copying of any kind
//without the express and written permission of Internet Business Solutions SL is forbidden.
//Author: Vince Reid, vincereid@gmail.com
[red]Thanks for not posting our copyright code. [/red]
</div>


[/code]

PieMan
Advanced Member

United Kingdom
272 Posts

Pre-sales questions only
(More Details...)

Posted - 07/04/2019 :  02:45:59  
Hi John,

thanks for your reply, but Vince's copyright code was removed before I came back to the thread. Could you possibly post just your code and directions for installation?

Regards

Mike

Using ECT since 2003.

Edited by - PieMan on 07/04/2019 02:46:28

dbdave
ECT Moderator

USA
10406 Posts

Posted - 01/20/2021 :  20:19:46  
Just an update to this thread.
It seems there is a problem with John M's code and PHP 8.0+

As far as I know, my mod is all good with php 8.0+

If anyone has a problem with John's code and php 8.0+, please contact him with questions.

Thanks,
David
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.03 seconds. Snitz Forums 2000