Repeat group

erigon

New Member
Hi people.

I have two fields in a repeating group - starttime and endtime
I was wondering if its possible to use the last given endtime as the starttime for the new repeated row.

so lets say first row is starttime 8 o clock - endtime 9 o clock

user presses add group

starttime 9 o clock - end time ... blank

Hope to hear from somebody!
 
I suppose you can place some code on eval option of your starttime element default value and do something like this

create a query using php code and select the max endtime for that emplyenumber and return it...

I'm not a professional programmer, I'm a self learning student who's learning fabrik because i like it .... maybe someone else could give you a better solution.

btw this is my contribute and hope it was usefull :)
 
Last edited:
Thanks for your input but this is not what I am looking for

I making an input form for worked hours per employees.The employee will fill in the form per day. We will use this as timesheets.

Header Employeenumber

Details STARTTIME ENDTIME PROJECTNR HOUR

so:

header 400 (employee 400)

Details (repeatable group)
STARTTIME ENDTIME PROJECTNR HOUR
21-oktober 08:00 10:00 12381 (projectnr ) WORKHOUR +add group (BUTTON)
21-oktober 10:00 12:00 12381 (projectnr ) TRAVELHOUR

What i want to do (prefer without database query) is that when the add group button is pressed the endtime of 21 oktober 10:00 is the starttime of the next line.. as shown above.

In this case the employee only has to fill in his starttime once a day (most employees have a connected shift)

Hope somebody can help me!

I can see the copy function in the form.php and formgroup.php i thought i could use the VAR from there. Because the add group button can copy the entire row. I just want the row to be copied and the endtime copied over the starttime.

Hope this makes it more clear.
 
try to take a look here

http://fabrikar.com/forums/index.ph...setting-end-date-2-hours-after-the-start-date

Just to make some exercise i created a simple form for a one to many (or master detail )relationship like yours
on the master side i had employee number field
on the detail repeat group i have two time field : start_time and end_time
placing some php code that makes a simple dbquery on default data of start_time and setting eval to yes i was able to achieve what you want... when i add a new row on repeat group table the previos end time is the value for the new start time....

the bad thing is that to make it work you have to save the form every time you add a new detail row....

without a dbquery i think that the only way to achieve your goal is using some javascript.... but i still don't know how to trigger an event when you push the add group button...
In the next days in my free time i will read the wiki and i will try to win this challenge :).
 
Warms my heart to see folk helpin' folk.

The event you need is fabrik.form.group.duplicate.end, which is fired as the last thing we do when duplicating a group, and which we pass the event object, the numeric group ID, and the current repeat count. So ...

Code:
Fabrik.addEvent('fabrik.form.group.duplicate.end', function(event, groupid, repeatCount) {
   if (groupid === '123') {
      // Your Code Goes Here
   }
});

Obviously replace 123 with your group's numeric ID. You should then be able to get at the previous group's end date, as you have the repeatCount, which you can use to build the element name you need, remembering that we append the repeat count to repeated element ID, like yourtable___end_date_4, or whatever.

-- hugh
 
Ok thanks!

My form id is 1
My group id is 2

So I made the javascript 1.js and put it in components/com_fabrik/js/1.js

My endtime table__field is the following: ureninvoer_2_repeat___eindtijd

so now i have this:

Fabrik.addEvent('fabrik.form.group.duplicate.end', function(event, groupid, repeatCount) {
if (groupid === '2') {

//note to self: MY :) Code Goes Here change form_1 to my form

var element_id = elements[elements.length - 1].id;
Fabrik.blocks.form_1.formElements.get(element_id).update(lastVal); ??

var endtime ...?

}
});

Is repeatCount correct? I thought it was repeatCounter


Oh yeah and how do i Run the variable in default eval for the begintime element.. $endtime?


This is another thread. Almost the same as i wish i guess....
http://fabrikar.com/forums/index.ph...repeated-group-based-on-previous-group.26238/

He uses:
Fabrik.addEvent('fabrik.form.group.duplicate.end', function(form, event, g_id, r_count){
var games = $('group16').getElements('select[name*=mps_matches___game]');
games[r_count].selectedIndex = games[r_count - 1].selectedIndex;
});
 
Fabrik.addEvent('fabrik.form.group.duplicate.end', function(event, groupid, repeatCount) {
if (groupid === '2') {
// Your Code Goes Here
var eindtijd = $('group2').getElements('input[name*=ureninvoer_2_repeat___eindtijd]');
eindtijd[repeatCount].selectedIndex = eindtijd[repeatCount - 1].selectedIndex;
}
});

Tried this one.. no result

with as default eval return $eindtijd
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top