Repeat field on next record

jesperlowe

New Member
Hello all

I?m designing a application for registration of cash donations, that are gathered once a year.
On the day they are gathered we have them counted in a local bank, and we want to "input" the in the database manually as they are counted.

I have a form for the bank staff with these fields
Area (parts of the town, Middel, East, West, South and other parts with town names)
Collection ID (number that is new every year and is a unique to the collection route and collector)
Amount in notes (Currency counted in notes/bills)
Amount in coins (Currency counted in coins)

And off course a save and new button.

As we count each part of town separately it would be nice if the Area field would repeat the "Area" used in the last form, and give focus to the collection ID field.

IS there anyway i can do this ?

a little "touch" is that we can have multiple personnel inputting these numbers from different areas of the town so you can't just look at the last record created... because it might be another user that just input a donation from another town area.

Best Regards Jesper
 
If you also have a user element on the form, which records the userid of the person submitting, you could have an eval'ed default which looks up the last row for that user ...

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myUser = JFactory::getUser();
$myQuery->select('area')->from('yourtable')->where('userid = ' . $myUser->get('id'))->order('id DESC');
$myDb->setQuery($myQuery);
return $myDb->loadResult();

Depending what element type it is, you might need to check if there's a value, and if not, reutrn your default value.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top