Gossamer Forum
Home : Products : DBMan : Customization :

View records, select w/ Checkbox and save as text file

Quote Reply
View records, select w/ Checkbox and save as text file
Well, over the past 60 days I have been having a lot of fun and have been learning alot from this forum!!!! You folx are awesome! I new nothing when I started this project. Now, I could really use some guidance.

What I currently have are 2 databases setup in a relational configuration. One is User.db the other is Status.db. They both use status.pass for authorization.

The User.db autofills the add_record form when a new status is entered and it emails me and the submitter the results in a formatted email.

So, I have installed the record mail, relational, autofill and write to text file mods.

Now, to the real stuff! (thanx for the opportunity to toot my own horn! Smile)

I want to be able to have my boss query the status.db with a date range (I am working on this now) and when the results are displayed, there will be a check box next to each record, similar to the delete_records process. He should then be able to select the records he wants via the checkboxes, then click a button that would write those records to a text file in a formatted fashion.

I have looked at the validate mod, but am not sure that it is what I am looking for.

Can anyone point me in a direction to look in or provide me some guidance on how to accomplish this? Let me know if I need to post some code or something? I am soooooo close to having what I want and any help will be greatly appreciated.

Thanx,

John

PS I have searched this forum alot and the Unofficial FAQ until my eyes hurt Crazy

Last edited by:

jlamphear: Apr 6, 2004, 3:08 PM
Quote Reply
Re: [jlamphear] View records, select w/ Checkbox and save as text file In reply to
Look in the FAQ under "Records" and on/about page 3 is this subject "Output fields to a text file (sub html_printout) ".

I think this will do what you want (perhaps with a little hacking).
Quote Reply
Re: [Watts] View records, select w/ Checkbox and save as text file In reply to
Thanx for the quick response Watts.


In Reply To:
Look in the FAQ under "Records" and on/about page 3 is this subject "Output fields to a text file (sub html_printout) ".

I think this will do what you want (perhaps with a little hacking).

I installed that mod yesterday. It allows me to do a search and display the results to either the screen or save in a text file based on what your query returned.

What I am hoping to do, is similar, only to display the records with checkboxes for selection, as all records that are returned from the query might not be needed to send to the text file.

I definately see using this mod as part of the solution, but I need a middle step. Here is what I am doing.

  1. Employess A, B, C, D, E login into the status.db and submit their monthly reports as a record.
  2. Boss recieved report in formatted, date stamped email.
  3. When all reports are recieved, Boss needs to do a monthly report roll-up.
  4. Boss logs in and performs a query (keyed to date range)
  5. Only the highlight and detail field information is displayed from each record, 1 for each employee
  6. Boss thinks only highlight & details from Employees B, D, E are significant accomplishments to share with Executive Management. Boss would them select checkboxes for those records.
  7. Boss then submit's, and previews proir to saving.
  8. Information is sent into a formatted text file and copied to Executive via email.
  9. Text file is displayed on a Monthly Highlights html page.

What I am looking at now, is possibly taking copies of the delete_search, delete_form & delete_success sub routines, modify from delete to go to the html_printout routine then to a report_success (like add_success) and use the email function.

The problems that I see (based on my limited knowledge) is knowing what to replace the value=delete calls within the certain areas of the code, especially the checkbox stuff.
#############
# In html.pl
#############

I think if I copy delete_search to report_search and replace the delete_form with a report_form sub call (modified copy of delete_form), I should be OK. eg. of report_search code changes:

<P>Search the database for the records you wish to include or
<A HREF="$db_script_link_url&report_form=1&$db_key=*">list all</a>:</p>
|; &report_form(); print qq|
|; &html_search_options; print qq|</p>
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="report_form" VALUE="Search"> <INPUT TYPE="RESET" VALUE="Reset Form"></center></p>
|; &html_footer; print qq|

***Now, here is where my limited cut and paste coding may get me in trouble! Then, in the new report_form (copied from the delete_form) sub, change the following to make it point to report_record (copy of html_record with limited fields displayed from each records)

for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TABLE BORDER=0><TR><TD><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"></TD><TD>|;
&report_record (%tmp);
print qq|</TD></TR></TABLE>\n|;
But I am not sure what to do with the checkbox Value="delete". Would I point this to preview_record in db.cgi? I say this as I believe delete is a function being called from somewhere within db.cgi***

Then, I would send them to the preview_record sub routine.
print qq|
<p>
<table border=0 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td>
<p><center><INPUT TYPE="SUBMIT" NAME="preview_record" VALUE="Preview Record"><INPUT TYPE="RESET" VALUE="Reset Form"></center></p>
|; &html_footer; print qq|

This is from the preview_record sub The add_record is being called from db.cgi.

print qq|
<form action="$db_script_url" method="POST" name="form1">
<center><INPUT TYPE="SUBMIT" NAME="add_record" VALUE="Add It!"><HR></center>
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
|;

So, this is where I need to have it make a call to print the records to a text file then go to something like report_success, that would do the mailing of the report.

I hope this makes sense, as I think I am close, but I have hit the wall.

Thanx for any and all input.

John
Quote Reply
Re: [jlamphear] View records, select w/ Checkbox and save as text file In reply to
If i were doing something like this i would make it simple by perhaps creating another field called monthly_highlights and having this be for adding a specific date. (make it available to admin only)

Then using the mod mentioned by Watts setup your custom search form to be able to choose by this field the date you want to export to the text file.

<TR><TD><$font>Monthly Highlight Date:</FONT></TD><TD>|; print &build_select_field_from_db("monthly_highlights",$rec{'monthly_highlights'}); print qq|</TD></TR>

If you're using the short/long mod you could include a quick link to modify the record so the admin could enter a date in the new field.

Just a suggestion. This would also be a way of getting information from previous monthly highlights as the date would remain in the db.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] View records, select w/ Checkbox and save as text file In reply to
Thank you for the reply LoisC as from reading the forum, I have learned to respect your knowledge and understanding of DBMan.

With your suggestion, the problem is, as I see it, is that several employees submit their reports on the same date (the due date) I have it working where the boss can query the date range (monthly) and it will save the query in the formatted .txt file, but it is all inclusive of all records within that data range. (this is with the Mod Watts suggested)

With that said, I guess I could have the boss list all records within the date range, make a note on paper of the ones he wants in the roll up report, then query each record individually by viewing by date range and employee than having these be appended in the .txt file. I think that it would probably work that way, but, it isn't really anymore automated than cut & paste from the individual emails and creating the roll up (how it is donetoday). I am trying to simplify the process and that is why I am trying to opt for the checkbox approach. I am under the assumption that this functionallity will work with some modifications of what function is being called and what the checkboxes represent.

I have replicated the delete_search, delete_form and delete_success subroutines and have called them report_search, report_form and report_success. I am now getting an error that states

Error: Unknown Action
The database program received a command that it did not understand.

I get this by calling db.cgi?db=status&report_search=1

My thoughts are now is that probably modification of the Modify Routines would be better. It seems more condusive to what I am looking to do. Copying the routines and replace modify_ with report_ in the routines. Do I need to tell db.cgi that there is another subroutine? I wouldn't think that it would be to difficult, I am just obviously overlooking something (or better yet, don't know of something! Shocked)



Last edited by:

jlamphear: Apr 7, 2004, 11:42 AM
Quote Reply
Re: [jlamphear] View records, select w/ Checkbox and save as text file In reply to
For the unkown action error...

Make sure you add your new subroutines in db.cgi under "Main" by listing them here:

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{'view_search'}) { if ($per_view) { &html_view_search; } else { &html_unauth; } }
elsif ($in{'view_records'}) { if ($per_view) { &view_records; } else { &html_unauth; } }
elsif ($in{'delete_search'}) { if ($per_del) { &html_delete_search; } else { &html_unauth; } }
elsif ($in{'delete_form'}) { if ($per_del) { &html_delete_form; } else { &html_unauth; } }
elsif ($in{'delete_form_archive'}) { if ($per_del) { &html_delete_form_archive; } else { &html_unauth; } }
elsif ($in{'delete_records'}) { if ($per_del) { &delete_records; } else { &html_unauth; } }
elsif ($in{'delete_records_archive'}) { if ($per_del) { &delete_records_archive; } else { &html_unauth; } }

Notice how the "else {&htm_unauth;} gets called if it doesn't find the subroutine listed here? This is just the top part of the set of if/then statements that verify the permissions to do certian things. You'll also notice I've added some for the Archive Records Mod.

You may want to investigage using the Archive records mod but turn off the part the actually deletes the records from the main db (?). Not sure...
Quote Reply
Re: [Watts] View records, select w/ Checkbox and save as text file In reply to
Watts,

Thanx for the enlightenment! Shocked I was just looking at the elseifs when you wrote. I am looking at the Archive mod now. It appears as though that will be a workable solution based on what I want to do. Thanx for that too!

What I am going to look at with the Archive Mod is to view the records, select them and instead of deleting and moving to another file, have it call the printout mod and create the text file. Should work wouldn't you think?

I will keep youposted on what happens. If you have any suggestions around working with the Archive mo9d, please let me know.

You guys (gals) are awesome!
Quote Reply
Re: [jlamphear] View records, select w/ Checkbox and save as text file In reply to
I've never used the archive mod but after searching to help you find a solution that also popped into my head as a possible solution.

I also found this thread which I thought might work to choose records with a checkbox:

Thread: http://gossamer-threads.com/p/000543
Topic: Problem Passing Variable
marksat - July 18, 1999

I'd be interested in knowing if the archive mod works out for you.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/