Gossamer Forum
Home : Products : DBMan : Customization :

Short Record Display on Modify Record

Quote Reply
Short Record Display on Modify Record

Okay... I'm sure I'm getting annoying by now Frown


When a user modifies a record, I only want them to be able to change certain fields. Easy enough to do, obviously. My problem is that instead of the "Modify" link bringing a user to the modify search form, it brings them straight to modifying multiple records (I have it set so they can only modify their own records), unless they have Admin access, in which case it brings them to the modify search form. That works just fine, but I only want the users to see the short display (which is the only info they can modify) instead of each long record display.

Does that make ANY sense at all?


I'm awful with words... and they say that a picture is worth a thousand words, so here...


This is what the regular user (Lone Ranger) should see when they click "Modify"



But if an admin (we'll say Wyatt Earp) clicks "Modify" they should be brought to the search page (like I said, I already have that part figured out) and if they DO decide to modify multiple records, then they should see:


(please note I threw those images together in about 5 seconds in Frontpage... this is not what my database looks like Angelic)


Does that make more sense? I wish I was more literate. It would help greatly. Anyhow, if anyone can decipher what I am trying to convey, your help is GREATLY appreciated!

Quote Reply
Re: [Reyhan] Short Record Display on Modify Record In reply to
ok, if i understand you correctly, the modify link should take everyone to the search form. the query will automatically filter the records to show regular users only the ones they have permission to see and the search form gives them a way to refine the search even more. so that functionality is already part of the program.

li suggest setting up a new routine html_record_form_modify to use for regular users when modifying records. include the following at the top:
Code:
my (%rec) = @_;
($per_admin and &html_record_form(%rec) and return);

that way you don't have to create a special form for admin to modify. it will use the regular one. (call the multi mod form if appropriate instead of html_record_form).

then in the new sub, set it up like the short display in the picture and use hidden fields for all the admin stuff.

hope this helps.
Quote Reply
Re: [delicia] Short Record Display on Modify Record In reply to
I don't want the Modify link to take everyone to the search form. I want it to take regular users straight to modifying all of their records in short record display, and it should take admins to the search form.
Quote Reply
Re: [Reyhan] Short Record Display on Modify Record In reply to
I would suggest adding to your short display a link directly to each record using:

|;
print qq! <A HREF="$db_script_url?db=$db_setup&uid=$db_uid&modify_form_record=1&modify=$rec{$db_key}">Modify</A> ! if ($per_mod);
print qq|

This way they can go directly to the modify form for each record they have submitted.

Then in your sub html_record_form for each of the fields that you only want them to be able to modify use the following example:

<TR><TD><$font>Stable:</font></TD><TD>|;

if (($per_admin) or (!$in{'modify'})) {
print qq|<INPUT TYPE="TEXT" NAME="stable" SIZE="30" VALUE="$rec{'stable'}" MAXLENGTH="45">|;
}
else {
print qq|<input type="hidden" name="stable" value="$rec{'stable'}">$rec{'stable'}|; }
print qq|</TD></TR>

Hope this helps. There are other suggestions in the DBMan FAQ.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Short Record Display on Modify Record In reply to
I'm not sure I understand. I'm sorry, I'm not very good at this whole programming thing yet. Give me three mores years in my database administration major, and I'll give you a run for your money Wink Is there not a way to incorporate the short record AND modify multiple records? And even if the only plausible was to do it is your way, LoisC, I'm not sure I follow exactly what I would be doing. You will have to forgive my ineptness Unsure
Quote Reply
Re: [Reyhan] Short Record Display on Modify Record In reply to
Are you using the mod to for modifying multiple records? I've never used that mod myself, I would have to check it out.

You can't just modify from the short display itself. You would have to view the record form to make the changes.

If you post the portion of your sub html_record_form and list the fields which you don't want to allow people to modify, I'll make the changes for you .

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Short Record Display on Modify Record In reply to
Yes, I am using the Modify Multiple Records Mod.

http://www.hermesmarketing.com/cgi/vsgea/db.cgi?db=default&uid=default&view_records=1&VSGEA=*
That is my short display, from the default user view of course.

http://www.hermesmarketing.com/cgi/vsgea/db.cgi?db=default&uid=default&view_records=1&VSGEA=*&nh=1&mh=1
An example of the long display.

http://www.hermesmarketing.com/cgi/vsgea/db.cgi
(I haven't configured the layout for all the pages yet Blush)
User name: Rebecca
Password: hello

Click Modify
Now... I want a kind of short display for this. I want it to list all the horses for the owner (in this case, Rebecca) in a table, like in the short record display, with the Last Vet Visit, Last Farrier Visit, and Points fields that can be edited.

This is EXACTLY what I want Rebecca to see when she clicks "Modify"
But if the Admin decides to click on "Modify" it will bring them to the search form, as usual, with the option of modifying multiple records. However, if the Admin should decide to modify multiple records, then it brings up all the appropriate records in the regular record form display.


sub html_modify_mult_form {
# --------------------------------------------------------
# The user has searched the database and requested to modify multiple
# records at once. A form for each record is present along with a checkbox
# on which record to use.
#
my ($status, @hits) = &query("mod");
my ($numhits) = ($#hits+1) / ($#db_cols+1);
if (($numhits == 1) and !$in{'nh'}) {
$in{'modify'} = $hits[$db_key_pos];
&html_modify_form_record();
return;
}

&html_print_headers();
print qq|
$html_head
<form action="$db_script_url" METHOD="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<h1><span></span>Update Multiple Horses</h1>
Make sure to check the box next to each record you update so that it will save!<br>
Your search returned <b>$db_total_hits</b> matches.</font>
|;
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
# Go through each hit and convert the array to hash and send to
# html_record for printing. Also add a radio button with name=modify
# and value=key.
if ($status ne "ok") { # Error searching database!
print qq|<P><FONT COLOR="RED" SIZE=4>Error: $status</FONT>|;
}
else {
print "<P>";
for (0 .. $numhits - 1) {
%tmp = &array_to_hash($_, @hits);
print qq|<TABLE BORDER=0><tr><TD><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="modify"></TD><TD>|;
&html_record_form_mult (%tmp);
print qq|</TD></tr></TABLE>\n|;
}
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}
}
print qq|
<p>
<table border=0 bgcolor="#DDDDDD" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td>
<P><center><input type="SUBMIT" name="modify_mult_record" value="Modify Records"></center></p>
|; &html_footer; print qq|
</td></tr>
</table>
</blockquote>
</body>
</html>
|;
}


Maybe the easiest way to do this would be in this subroutine, add an if permission admin then *insert the corresponding regular record form code here* else if permission modify then *insert corresponding short record form code here*
However, I have no idea if this would work. And even if it would, I don't know how to do it because where it says
&html_record_form_mult (%tmp);
I'm assuming it is calling the build_html_mult_record_form thing, and I don't know how to call that within actual form coding. Like I said, I'm still learning all of this.

I've confused myself, I think.

Last edited by:

Reyhan: Aug 22, 2008, 9:38 PM
Quote Reply
Re: [Reyhan] Short Record Display on Modify Record In reply to
change:
sub html_record_form_mult {
# --------------------------------------------------------
#
my (%rec) = @_;
print &build_html_mult_record_form (%rec);
}
to:
sub html_record_form_mult {
# --------------------------------------------------------
#
my (%rec) = @_;
($per_admin and print &build_html_mult_record_form (%rec) and return);
print qq|<input type=hidden name="Horse-$rec{$db_key}" value="$rec{'Horse'}">$rec{'Horse'}</td>
<td><input type=hidden name="Owner-$rec{$db_key}" value="$rec{'Owner'}">$rec{'Owner'}</td>
<td><input type=text name="Vet_visit$rec{$db_key}" value="$rec{'Vet_visit'}" size="$db_form_len{'Vet_visit'}"
maxlength="$db_lengths{'Vet_visit'}"></td>
<td><input type=text name="Farrier$rec{$db_key}" value="$rec{'Farrier'}" size="$db_form_len{'Farrier'}"
maxlength="$db_lengths{'Farrier'}"></td>
<td><input type=text name="Points$rec{$db_key}" value="$rec{'Points'}" size="$db_form_len{'Points'}"
maxlength="$db_lengths{'Points'}"></td><td>
<input type=hidden name="Everything_else-$rec{$db_key}" value="$rec{'Everything_else'}">
|;
}

where i have Everything_else you will need to list all the fields separately except for the five that are displayed in the short display. i haven't tested this but it should be close to what you want. the line with $per_admin pulls the default build_record which has a separate row for each field and a separate table for each record. if not admin, the rest of the code builds a one-row table for each record; the opening and closing of the table is in the sub sub html_modify_mult_form. hope this helps!