Cactiusers.org


It is currently Mon May 21, 2012 5:18 pm




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
 Weekly and Monthly reporting feature for Report Plugin 
Author Message
User

Joined: Wed Aug 30, 2006 4:18 am
Posts: 45
Post Weekly and Monthly reporting feature for Report Plugin
Hi All,
I have added some code to the code published by Jimmy under the forum http://cactiusers.org/forums/topic645.html to allow report plugin to send weekly and monthly report.
For Weekly report it will send report on every Monday and for Monthly it will send report on the date of 1st of every month.
I attached only 2 files that I made the amendment. For the rest of the file please retrived from the above forum

For those users who want to just do a slight modification on the SQL table, you can run this in mysql

mysql> ALTER TABLE reports ADD freq VARCHAR(1) NOT NULL DEFAULT 'd';

Note that this command is for those who is following the above forum. As for the reports.sql file, please do not use it unless your want to discard the old SQL table in the report0.1b.

Still in testing progress


Attachments:
monthly.JPG
monthly.JPG [ 76.46 KiB | Viewed 1767 times ]
reportnsetup.zip [4.62 KiB]
Downloaded 285 times


Last edited by poly on Wed Jan 10, 2007 7:53 pm, edited 2 times in total.

Mon Jan 08, 2007 10:36 pm
User

Joined: Wed Aug 30, 2006 4:18 am
Posts: 45
Post 
Hi Jimmy,
I discovered a bug on the reports.php. Whenever you create new report and add new report to it for the "inline png", the url will be /plugins/reports/reports.php?report=$id instead of /plugins/reports/reports.php?report=1 or other no. It seems that the hostid is not posted to the URL.
Resulting that the text and graph created are not given the correct hostid. THis does not apply for clicking the edit the exisiting report. it only happens when you create a new report.
I found that this line is injected from reports.php, under template add
if ($id) {
Header('Location: reports_edit.php?report=$id');
exit;
What should I do?

regards


Tue Jan 09, 2007 5:38 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
poly,

This looks like a good addition to the Reports plugin, I will test out later today.

A feature for this plugin which I would like to see is the ability to add a graphic/logo to the report, any ideas how to do it?

I'm going to post it over on the Feature Request forum, while I try and work it out myself.

Argon0


Tue Jan 09, 2007 6:39 am
User

Joined: Wed Aug 30, 2006 4:18 am
Posts: 45
Post 
Hi Jimmy,
I found the bug and solved. Now I dont have the problem in adding text and graph to the new report. I have updated the report.php in the above attached.

Regards


Wed Jan 10, 2007 4:06 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
So, Poly, what we need to do is replace reports.php and setup.php in the reports plugin directory, then run the sql query you mention above?

Am I right?

Any help you can give me with adding a logo to the reports?

Argon0


Wed Jan 10, 2007 6:39 am
User

Joined: Wed Aug 30, 2006 4:18 am
Posts: 45
Post 
Hi,
Yes that replacing the 2 files would do. Note that Jimmy has made changes to the database tables as from ver 0.1b. If you are using the latest version from the above mentioned forum. Just need to execute the command mentioned above to alter the current table.
As for the logo, I dont have the idea where to modify. However, I will take note of it.

regards


Wed Jan 10, 2007 8:18 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
Well I've worked out how to "hard code" it into the PDF and the Preview reports:

Preview:

Code:
   print "<center><img src='../../images/GroupM_logo.jpg'></center>";


PDF:

Code:
function reports_generate_pdf ($subject, $filename, &$mail, $output = 'S', $logo = '/var/www/html/images/GroupM_logo_new.PNG') {
...
...
   $pdf -> Image($logo, 1, 0, 0, 0, 'PNG');


What I need to do now is work out how to get the variable $logo defined from the web interface/wizard - worked out how to add an entry to the drop down list, and get it to mirror the text input....


Thu Jan 11, 2007 6:12 am
New User

Joined: Wed Mar 22, 2006 4:07 pm
Posts: 15
Post 
Maybe there is some easy way of not making the graphs stretch across the whole page when generating the PDF? It would just make the report look better I think.

/Carl


Fri Jan 12, 2007 8:33 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
I'm sure there must be the variables for the PDF -> IMAGE command must include a sizing factor, as well as as justification...

I shall dig...


Mon Jan 15, 2007 7:01 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
FPDF is the extension being used...

More info over here ===> http://www.fpdf.org/


Mon Jan 15, 2007 9:46 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
YUp, it is possible you just have to decide how wide you want the images to be and specify it in the functions.php file - on the line

Code:
$pdf->Image($fn, 1, $ypos, 0, 0, 'PNG');


(which is, I think, line 251), the width is specified in the 4th variable - i.e. if you wanted it to be 200 units wide (now I don't know what units it uses, by default it will use 72dpi.....): $pdf->Image($fn, 1, $ypos, 200, 0, 'PNG');

Argon0


Mon Jan 15, 2007 10:02 am
New User

Joined: Wed Mar 22, 2006 4:07 pm
Posts: 15
Post 
Thanks!

Had to work with the image size and the pdf dpi size a bit to get a good crisp image, but now it works lika a charm.

Also read a bit on the FPDF page, and there are lots of cool things you can do there :)

/Carl


Tue Jan 16, 2007 4:01 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
What image size did you use?


Wed Jan 17, 2007 3:20 pm
New User

Joined: Wed Mar 22, 2006 4:07 pm
Posts: 15
Post 
It's not completely crisp, but it's ok. I'm finding it hard to understand how it all goes together. If I define the graph to 200x600, and I set the $pdf->Image hight dpi to 100, I think my graph should be around 2 inches, but it is not.

Or if I want a crisp picture, I would like 300 dpi, but setting the graph hight to 600 will not result in a roughly 1 inch high image.


Anyway, I use graph hight 200, width 600. I have also made a change to make spacing better between the graphs with these settings:

$h = ($h[1] / 4.50);

and finaly:

$pdf->Image($fn, 11, $ypos, 140, 0, 'PNG');

I get 3 graphs per page with these settings with one row of font size 10 text above.

/Carl


Thu Jan 18, 2007 5:04 am
User

Joined: Mon Jan 16, 2006 12:14 pm
Posts: 121
Post 
Does the 140 refer to DPI? or a percentage or ?


Fri Jan 19, 2007 6:39 am
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: