Gossamer Forum
Home : Products : DBMan : Customization :

Adding a Subroutine

Quote Reply
Adding a Subroutine
Hello all! I'm in the process of learning Perl lingo and am quite stuck on a certain problem. I hope someone can help.

I basically have 2 html.pl files, one for students input and the other for staff to view the records put in by students. For the staff html.pl (called admin.pl), I'd like for them to select on the view_search page the study abroad program of choice (ie., France, Germany, Italy, etc) that they want to get info from their students. Once they make selection of which program to gain info from, I want to also have an option of what output to receive (ie., name & address for one, financial info for another, etc.). I'm assuming that this should be set up through html_record. I've tried to create a subroutine for the different types of output, but that has failed. I believe my main problem is in the db.cgi Main Menu "switches". Is this possible? Any help is much appreciated!

Brian

Quote Reply
Re: Adding a Subroutine In reply to
Actually, you need to edit sub main in the db.cgi script when adding "subroutines"...look at the series of elsif statements in the db.cgi script...

Regards,

Eliot Lee
Quote Reply
Re: Adding a Subroutine In reply to
Thanks Eliot.

I'm also interested in finding out what to put & where precisely to put it. Using html_report_demographics as my subroutine name, I have found the following:

elsif ($in{'report_demographics'}) { &html_report_demographics; }

Where exactly should I put this in the sub main? I have tried the above, but it would not work. I assume it was in the wrong place.

Thanks

Brian

Quote Reply
Re: Adding a Subroutine In reply to
You also need to add the $per_view codes...look at the other elsif codes...without the permission condition, you will get an Unknown Action error.

Regards,

Eliot Lee
Quote Reply
Re: Adding a Subroutine In reply to
Thanks again, Eliot. That worked. However, I'm not sure if what I want to do will work. I'm hoping to have an html_record output based on the selection that they make on reports. For instance, if the user wants to receive a report on demographic information, they can select it html_view_search and the html_record will only display those particular results. I was hoping to side-step having to create separate html.pl & cgf files for each individual report and have it all go through one script, but I'm thinking that may be to complicated. Any thoughts? Thanks!

Brian

Quote Reply
Re: Adding a Subroutine In reply to
There is a mod in the FAQ noted below under the section "Viewing" which may help you to understand how to create your reports and provide some ideas.

The thread is called "Creating A Reports Routine". If you view several other related threads, you may come up with exactly the solution you are looking for.

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Adding a Subroutine In reply to
LoisC,

Thanks for the post. Somehow I missed that mod when I was looking. I tried it and for some reason it did not work with me. GOOD NEWS, however. I believe I have found a quicker solution, but I have one other question:

From my html_view_search page, I have simply put in a radio input to select the type of report, like this (for the sake of space, i only included 2 of them):

<INPUT TYPE="radio" NAME="reports" value="questions"> Questions Report

<INPUT TYPE="radio" NAME="reports" value="address"> Address Report


and I have also created in the html_record output the following to correspond with the above radio:

if ($reports eq "questions") {
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#f7dec8">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Questions:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Your_Questions'}</Font></TD></TR>
</TABLE>|;
}
elsif ($reports eq "emergency") {
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#f7dec8">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Address:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Address'}</Font></TD></TR>
</TABLE>|;
}
else {
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#f7dec8">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Study Abroad Program:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Program'}</Font></TD></TR>
</TABLE>|;
}

There is something not quite right with this. I mean, it does everything but show the right report. It simply defaults to the "else" statement at the end and never shows the others. I know this is showing my ignorance, but how do I do scalar variable for the input name="programs"? is there an easy way to indicate to the if/elsif/else statements the scalar varaible for a radio button name field?

Any help is appreciated. Thanks in advance!

Brian

Quote Reply
Re: Adding a Subroutine In reply to
Brian, on your if statements, try using the brackets and single quotes around them such as:

elsif (($reports) eq 'emergency')

~ Karen

Quote Reply
Re: Adding a Subroutine In reply to
Have you already assigned a value to $reports? If not, then it will always return nothing, which would be why your if/elsif is always failing.

Try: if ($in{'reports'} eq 'questions') {

Hope this helps.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Adding a Subroutine In reply to
Mark & Karen,

Thanks for the info. Last night I tried everything and finally I got what Mark recommended to work! YEAH!

For the boys & girls who want to know,

if ($in{'reports'} eq 'questions') {whatever i want them to view for the questions report};

this worked like a charm! Thanks again!

Brian


Quote Reply
Re: Adding a Subroutine In reply to
Brian, pleased to hear Mark's solution worked for you. I learn so much from his informative posts.

Good luck!