Gossamer Forum
Home : Products : DBMan : Customization :

select field and dbase printing

Quote Reply
select field and dbase printing
Hi JP!


when using the modify option, one of my fields (doctype) uses the db_select_field mod and it is automatically set to <blank>. is there any way that the field will preserve its old value unless the user wants to select a new value for it?

likewise, i would like to know if there is a mod that will allow the admin to print a summary of the database. what i mean with summary is that it would contain some of the most important fields to be printed in a tabular form.

tia.
Quote Reply
Re: select field and dbase printing In reply to
I don't know the answer to the first question.

With regards to the second question...What you could do is create another sub-routine that will allow the administrator to view a separate table of data.

Follow these instructions:

1) Insert the following codes:

Code:
elsif ($in{'print_view'}) { if ($per_view) { &print_view; } else { &html_unauth; } }

AFTER the following lines of codes in the sub main in default.cgi:

Code:
if ($in{'add_form'}) { if ($per_add) { &html_add_form; } else { &html_unauth; } }
elsif ($in{'add_record'}) { if ($per_add) { &add_record; } else { &html_unauth; } }
elsif ($in{'preview_record'}) { if ($per_add) { &preview_record; } else { &html_unauth; } }
elsif ($in{'view_search'}) { if ($per_view) { &html_view_search; } else { &html_unauth; } }

2) Add a sub-routine called sub print_view in default.cgi AFTER sub view_records:

Code:
sub print_view {
# --------------------------------------------------------
# This is called when a user is searching the database for
# viewing. All the work is done in query() and the routines just
# checks to see if the search was successful or not and returns
# the user to the appropriate page.

my ($status, @hits) = &query("view");
if ($status eq "ok") {
&html_print_view(@hits);
}
else {
&html_view_failure($status);
}
}

3) Create a sub-routine (could be called sub admin_view). Copy the html_record sub-routine and modify the sub admin_view to your liking. Use HTML codes and field names (e.g., $rec{'FieldName'}) to create the format you like.

4) In the sub view_search of the html.pl file, add these codes:

Code:
|;
if ($per_admin) {
print qq|<INPUT TYPE="SUBMIT" NAME="print_view" VALUE="View Printable Format">|;
print qq|

AFTER this line:

Code:
<INPUT TYPE="SUBMIT" NAME="vr" VALUE="View Records">

5) Create another sub-routine called sub html_print_view. You can copy the html_view_success.

6) Replace &html_record(%rec); with admin_view in html_print_view.

This should work. I have a similar routine working on the following web site:

www.coco.cc.az.us/cgi-bin/schedules/index.cgi?&uid=default

Of course, the difference is that the codes I've provided you are only for administrators to view versus the example, which allows everyone to view the records in a printable format.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 04, 1999).]

[This message has been edited by Eliot (edited August 04, 1999).]
Quote Reply
Re: select field and dbase printing In reply to
Usually the problem with values not being maintained in select lists on the modify screen is caused by extra spaces or linefeeds in your select list definition.

Code:
Right:
Fieldname => 'Option1,Option2,Option3'

Wrong:
Fieldname => 'Option1, Option2, Option3'

Wrong:
Fieldname => 'Option1, Option2,
Option3'

If that's not your problem, I may have to see your .cfg file to know what's going on.


------------------
JPD





Quote Reply
Re: select field and dbase printing In reply to
i made modifications to the build_html_record. before passing the value of $output, i checked out if there is a value for the $Doctype. using another variable, i stored the user input from the browser.

here's my code: (pardon my innocence in progg., though)

** before the foreach stmt:

my $wtype=$rec{'DocType'};

** after the foreach stmt:

$ano .= "</table></p>\n";
if ($wtype !=nil && $ano == nil)
{
$rec{'Doctype'}=$wtype;
}
{else $output .= "</table></p>\n";}
return $output;
Quote Reply
Re: select field and dbase printing In reply to
 
Hi Eliot!

actually, what i wanted also is a summary of the whole database. for example, my printable output will be:

Number DocNum Date Description Author

** and all the records with their corresponding field values are presented

but still i would like to have the option of making a search and print the search result.

btw, i tried your codes and instructions, first without modifying the sub admin_view (based on html_build_record) but i do not get anything... it ony says "you search returned x matches" no records displayed whatsoever.

please help....
Quote Reply
Re: select field and dbase printing In reply to
Oops...I saw two syntax errors in the codes I gave you:

1)

Code:
|;
if ($per_admin) {
print qq|<INPUT TYPE="SUBMIT" NAME="print_view" VALUE="View Printable Format">|;
print qq|

SHOULD BE

Code:
|;
if ($per_admin) {
print qq|<INPUT TYPE="SUBMIT" NAME="print_view" VALUE="View Printable Format">
}
|;
print qq|

2) When I stated the following:

Quote:
6) Replace &html_record(%rec); with admin_view in html_print_view.

I meant to state:

Replace the &html_record(%rec); with admin_view(%rec);....

Sorry about that.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 05, 1999).]
Quote Reply
Re: select field and dbase printing In reply to
Please save your html.pl and default.cgi files as text files (e.g., htmlpl.txt and defaultcgi.txt). Then upload the text files to a publicly accessible web directory on your web server. Then post the URL where I can find the files. Also post where we can access your database to look at it (as a guest). If you don't feel comfortable posting your files (because of security purposes), then feel free to email me the files and URL at eliot@anthrotech.com.

I will assist you in debugging the script. Smile

(Sorry if I am overstepping my boundaries, Carol. Since I posted the codes, I feel it is my responsibility to assist people if the codes don't work.)

Smile

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 06, 1999).]
Quote Reply
Re: select field and dbase printing In reply to
Not at all! Go for it!! Smile


------------------
JPD





Quote Reply
Re: select field and dbase printing In reply to
 
hi eliot!

i still get the same thing --> blank display Frown