AUTOINCREMENT INVOICE NUMBER WITH PREFIX

*sigh*

Sorry guys, I had forgotten to commit the changes.

https://github.com/Fabrik/fabrik/commit/d85fd61507e2d802f9c940fee8e320fc60e5c740

Long story short, I had to move the swapValuesForLabels() method out of the 'calc' element and into the main element model, so the 'sequence' plugin could share it. It's the code that, on submission, takes the value of any elements like dropdowns or radios (that have a concept of 'value' and a 'label'), and adds the label to the data. Which isn't usually present in submitted data. But things like calc, and now sequence, may want to use labels in placeholders rather than always getting the raw data.

Should work now.

-- hugh
 
(So to save a little time, you can just upload the four files referenced in that commit, rather than everything)
 
On Submit is ok now (fixed text and placeholder)
On Load shows the placeholder (but I think on Load with placeholder doesn't make sense, placeholder is not defined on load)
Use PK is still empty
 
On Load shows the placeholder (but I think on Load with placeholder doesn't make sense, placeholder is not defined on load)

Correct. Well, some placeholders would work - like {$my->foo}, or {$session->foo}, etc. But not elements.

Use PK is still empty

Oops, I'd only tested that while editing an existing row (it's the only mode which will write the sequence even when editing, which I'm not sure if it should do or not ... probably not ... I'll see if I can make it not do that ...)

https://github.com/Fabrik/fabrik/commit/08afd8a9a2f9cfacc5f120019092b48fbfd37e28

-- hugh
 
Then,
"on submit" is working
"on load": I don't understand what I have to do exactly
"PK": what is it?

Is the element sequence ready to use in a real proyect?
 
The wiki explains the differences, but I'll explain anyway:

Using On Load you can see the new serial number in the form, BUT you can end up with gaps in the serial, if someone loads a new form, but never submits it, and you can't use element placeholders in the affix (as element don't have values when you load a new form).

Using On Submit, the serial is created when the form is submitted. So you can't see the new serial in the form (it'll show a default message instead, like "will be assigned when for is submitted"), but you can use element placeholders in the affix. So this is the mode you need.

In both On Submit and On Load, the plugin maintains it's own incrementing numbers (in a new table called #_fabrik_sequences), rather than using the PK (rowid) of the form, so it can maintain separate sequences for different affixes (like your 2017- and 2018- case).

Using "Use PK", the serial number uses the form's rowid (PK, primary key value) rather than maintaining a separate incrementing count. This won't work for you, as you need the serial to start over for different affixes, but is OK for people who only use a single affix. Use PK mode is done after form submission, so it can use placeholders.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top