Jump to content
Sign in to follow this  
zzfritz

Admin report: Monthly Sales & Tax new version 1.3

Recommended Posts

I just posted an extended version of the income summary report:

 

http://www.oscommerce.com/downloads.php/co...ions,776/type,3

 

New features in this version:

open report in printer-friendly window;

download file of report data in CVS (comma separated values) for import to spreadsheet tools;

help screen;

optional columns for loworder fee and gift vouchers only if features enabled.

Share this post


Link to post
Share on other sites

Thanks to some testers a couple bugs have been discovered in this release.

 

First, you need to create this stylesheet for the printer friendly page, at admin/includes/printer.css:

body { background-color: #ffffff; color: #000000; margin: 0px; }

.pageHeading { font-family: Verdana, Arial, sans-serif; font-size: 18px; color: #000000; font-weight: bold; }

.dataTableHeadingRow { background-color: #ffffff; }

.dataTableHeadingContent { font-family: Verdana, Arial, sans-serif; font-size: 11px; color: #000000; font-weight: bold; }

.dataTableRow { background-color: #ffffff; }

.dataTableContent { font-family: Verdana, Arial, sans-serif; font-size: 11px; color: #000000; }

.smallText { font-family: Verdana, Arial, sans-serif; font-size: 11px; }

.main { font-family: Verdana, Arial, sans-serif; font-size: 11px; }

Also, a dummy file needs to be created at admin/temp.csv which gets deleted as a housekeeping matter; the revision will check for it before trying to delete it.

 

Finally, non-IE browsers are finding a javascript error. This will have to be fixed in a revision, which should be ready within the next day.

Share this post


Link to post
Share on other sites

Okay, the corrections are made and the printer.css included in the package:

 

http://www.oscommerce.com/downloads.php/co...ions,777/type,3

 

If your admin directory has file restrictions, be aware that this script creates a temporary file and may need to be given permissions dependent on the nature of your configuration and security protocol.

Share this post


Link to post
Share on other sites

I have installed the last 1.4 but I get allways this error message:

 

Warning: Unlink failed (Permission denied) in /home/........../www/html/admin/stats_monthly_sales.php on line 414

 

 

the attribute for file "temp.csv" are 777 , where can be the problem ?

 

Thanks

 

Tato

Share this post


Link to post
Share on other sites

Hi there,

 

Yes I get the same result.

 

I also checked the temp.csv file is 777.

 

Prints out fine except with that 'Perm denied' error message on it

 

Thanks Fritz this is a great addition and I'm sure this is just a little flea bug!

 

best,

 

ozstar

Share this post


Link to post
Share on other sites

depending on your OS , some will not accept to write in the a directory like admin where there is an htaccess file which could restrict permissions

 

(even if you add a dummy file and try to put 777 permissions on it)

 

 

a fast workaraound is the following

 

 

create in catalog/configure.php a line like

 

define('DIR_FS_TMP', DIR_FS_DOCUMENT_ROOT . 'tmp/');

 

 

// where a tmp writable directory is located on the server. if $DOCUMENT_ROOT doesnt suit you, replace with your local path. (eg, /usr/local/apache/htdocs)

 

 

you normally have PUB or TMP defined as a writable directory

 

 

 

 

In the report , add the DIR_FS_TMP before the name of the file

 

 

this way you will not write anything in the admin directory and it should work

 

it works for me. just make sure the writable directory you choose is Really a writable directory.

Share this post


Link to post
Share on other sites

What was the actual line you deleted and in exactly what dir/file.

 

Thank you both I'll give both a whirl..

 

Have a good day

Share this post


Link to post
Share on other sites

// done with report body

// save CSV as file

if ($num_rows>0) {

if (file_exists('temp.csv'))

//unlink('temp.csv'); here is the commented line

$f=fopen('temp.csv','w');

fwrite($f,$csv_accum);

fclose($f);

}

?>

 

and it works guys

Share this post


Link to post
Share on other sites

great contribution! much thanks.


The only thing necessary for evil to flourish is for good men to do nothing

- Edmund Burke

Share this post


Link to post
Share on other sites

Yes thank you all.

 

Commenting out that line, did the job.

 

Regards from a very smokey Sydney!!

 

ozstar

Share this post


Link to post
Share on other sites

I still get this error on top when I hit "Monthly Sales & Tax". For the rest it looks to be working fine!

 

 

0.00

 

Warning: fopen("temp.csv", "w") - Permission denied in /home/frying/html/catalog/admin/stats_monthly_sales.php on line 416

 

Warning: fwrite(): supplied argument is not a valid File-Handle resource in /home/frying/html/catalog/admin/stats_monthly_sales.php on line 417

 

Warning: fclose(): supplied argument is not a valid File-Handle resource in /home/frying/html/catalog/admin/stats_monthly_sales.php on line 418

 

 

Anyone got an idea?

 

Fry.

Share this post


Link to post
Share on other sites

There is a post on the 1st page of this thread with the answer.

 

I had the same problem and just // commented out 1 line and it works beautifully.

 

If you have the new version he posted in the pots bfeore yours, I believe you do not need to do anything as he kindly fixed it all.

 

Good luck.

 

Ozstar

Share this post


Link to post
Share on other sites

i have installed tha last contrib (with patch) and it works !! but i see in the top of header, over the months, this:

 

0.00

 

 

what is it ? is it possible to remove it ?

 

 

 

all the best

 

Tato

Share this post


Link to post
Share on other sites

Tato, I just reviewed the code and you encountered an error that only affects sites that have disabled the low order fee.

 

In admin/stats_monthly_sales.php v.1.4a, change lines 395-399 from

<?php if ($loworder) { ?>

<td class="dataTableHeadingContent" width='70' align="right">

<?php }; ?>

<?php mirror_out(number_format($ytd_loworder,2)); ?>

</td>

to

<?php if ($loworder) { ?>

<td class="dataTableHeadingContent" width='70' align="right">

<?php mirror_out(number_format($ytd_loworder,2)); ?>

</td>

<?php }; ?>

Share this post


Link to post
Share on other sites

First of all this is a great contribution. Nice work on it.

 

I have installed 1.4a which prints out my monthly totals fine - but I still get the errors on line 416,417 & 418. I have checked my file to ensure that it does not have the above mentioned "not needed" code that was causing problems. It seems fine there. If I delete out lines 416-18 no errors. Of course I can't download my csv file though... which would be VERY useful to me. When I try I simply get "file not found". Any suggestions?

Share this post


Link to post
Share on other sites

The pesky bit of code that is causing delirium :wink: and other bad reactions just saves the CSV data to a temporary file for download. I was unaware how much variation there is among servers in the behavior of the "unlink()" function that deletes files, and since it did not cause a fatal error on my Unix/Linux server, the original code deleted the file on every execution. That caused an error on some servers if the file did not exist, so I revised the code to check for the existence of the file before deleting it:

if ($num_rows>0) {

if (file_exists('temp.csv')) unlink('temp.csv');

$f=fopen('temp.csv','w');

fwrite($f,$csv_accum);

fclose($f);

}

On some servers this will work okay if you remove the second line altogether, and the code just overwrites the file if it is there. Some other servers give an error if you try to overwrite the file, and still others require tweaking to get write permission at all.

 

This is my first experience with the oddities of server file system treatment of PHP file functions. If anyone has a suggestion for universal bullet proof code, I'd love to see it.

Share this post


Link to post
Share on other sites

Does this mod only work on the new checkout csv?

 

I have installed it on a sept 02 release and while I get the table set up correctly on stats_monthly_sales.php there are no entries I just geta message :

 

No income found for this date/status selection

 

Help? If it is just for new checkout csv can the sql be rejigged for old style or am I wasting my time?


/* Intellectual property: are you for or against the human race? */

if ( you want exclusive ownership of an idea ) {

keep your idea to yourself;

// you greedy bastard

}

Share this post


Link to post
Share on other sites

Thanks a lot Fritz. I'll give this one a shot. And again - thanks for a very useful and needed contribution.

Share this post


Link to post
Share on other sites

Fritz,

 

you might want to revisit some bugs on this cont. I have replaced both code snippets and can't get rid of the 0.00 at the top of the page, nor get csv working.

 

The original problem that I had is down to having ot_subtotal disabled in admin, I don't need it and it confuses customers in the UK where we have enought vat/tax issues and clarity of pricing wins.

 

The sql query to get the orders uses a conditional where ot.class = ot_subtotal, essentially.

 

If its disabled you get blanks.

 

Much needed cont needs some tlc.


/* Intellectual property: are you for or against the human race? */

if ( you want exclusive ownership of an idea ) {

keep your idea to yourself;

// you greedy bastard

}

Share this post


Link to post
Share on other sites

This contribution does indeed assume that the subtotal is used, and furthermore, that the subtotal has been set up as the sum of product sales and does not include the additional elements of tax, shipping, loworder and voucher.

 

Given the many possible alternatives for the composition of order total, it may not be feasible to anticipate them all and implement the report to be universally adaptable.

 

Although it might have been apparent from calling the contribution a "Sales & Tax" report, and emphasizing in the description that it distinguishes taxable from exempt sales on the basis of the store zone, perhaps I should announce more explicitly that it is only useful for those of us in the provinces. Sorry, mate.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×