Gossamer Forum
Home : Products : DBMan : Customization :

Refresh Date Button

Quote Reply
Refresh Date Button
Hi, i need a MOD for a Formbutton, that set the Date - Record on the actually Database-Entry (e.g. on the modify-form) to the todays date. Simple the button must set the "get_date" to the database for the aktual entry. But im not so good in Perl.
Example: The user modify an entry than he should have a button to refresh the Date for this entry.

Kai
Quote Reply
Re: Refresh Date Button In reply to
I would suggest adding a field to the db_def section of your default.cfg file that is a ModifiedDate. This can be automatically generated by the &get_date routine. Set this field in the same manner for your AddDate field (if you have one).

This will show you two different dates in the record...Date Added and Date Modified.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Refresh Date Button In reply to
In html_modify_form_record after :
Code:
my (%rec) = &get_record($in{'modify'});
if (!%rec) { &html_modify_failure("unable to find record/no record specified: $in{'modify'}"); return; }

Add this:
Code:
$rec{'Date'} = &get_date();

Make sure to use $rec{'Date'} or the actual name of your date field.

------------------
WFMY-TV Webmaster
Quote Reply
Re: Refresh Date Button In reply to
WFMY-TV Webmaster: This is exactly what i need - thank you very much. Do you know, how i can perform this feature (set actual date) with an Formbutton in the Modify-Area?

Kai
Quote Reply
Re: Refresh Date Button In reply to
Try this. First, delete the $rec{'Date'} = &get_date(); code I gave you above.

In html_record_form, make the field $rec{'Date'} a hidden field.
<input type="hidden" name="Date" value="$rec{'Date'}">

Make another select field called "decide" (This field does not go in your config or database!):

<select name="decide">
<option value="keep">Keep last modify date</option>
<option value="change">Change to current date>/option>
</select>

Then in db.cgi, in sub modify_record:
Before:
Code:
$status = &validate_record;
Insert this code:
Code:
if ($in{'decide'} =~ /change/) {
$in{'Date'} = &get_date();
}


------------------
WFMY-TV Webmaster
Quote Reply
Re: Refresh Date Button In reply to
It works - thank you very much.

Kai