AUTOINCREMENT INVOICE NUMBER WITH PREFIX

cryptlan

Member
Hello,
I need help, I need to create an invoice system and the conditions are:
  1. prefix selected from dropdown (2017, 2018, ....)
  2. autoincrement number starting from 0 when the dropdown change.
e.g.:
List "invoices"
field dropdown "ivoices__prefix1"
result: prefix1+autoincrement

IVOICE NUM: 2017-0001, 2017-0002, 2017-0003, ...
and when I change the dropdown:
INVOICE NUM: 2018-0001, 2018-0002, 2018-0003, ...

Please help, I've been looking for any information usefull or that I could understand, but nothing.
It is very urgent because I have to get ready this before 2018.

Thanks,
 
Does the number have to show on the form while you are creating it, or can it be assigned during submission?

-- hugh
 
Do the numbers have to start at 0 for each year?

And do they have to be sequential, does it matter if there's the occasional gap?

-- hugh
 
in fact depending of the dropdown selected, it will be used for different series:
e.g.:
  • Selected in dropdown 2017
    • 2017-0001, 2017-0002, 2017-0003, ...
  • Selected in dropdown "Pre"
    • Pre-0001, Pre-0002, Pre-0003, ...
  • Selected in dropdown "Reciv"
    • Reciv-0001, Reciv-0002, Reciv-0003, ...
Is it possible?
 
Yes, it's possible, but I still need you to answer my last two questions.

Also, does the number ever change, i.e should it only ever be assigned when creating a new form, and then never changed?

-- hugh
 
Correct, the number can not be changed.
If anything is wrong the user has to create a negative invoice.
 
And what about these two question:

Do the numbers have to start at 0 for each year?

And do they have to be sequential, does it matter if there's the occasional gap?

I need to know, as this dictates what way we have to do this.

-- hugh
 
I do not want the autoincrement id dependig of the year of the date.
I need to start from 0 with each new prefix selected at the dropdown.
Normally the prefix will be the year but could be other, I will add prefixs to the dropdown from the administrator.


I'm not sure if I've explained myself well, excuse my english.

Thanks,
 
I do not want the autoincrement id dependig of the year of the date.

Yes, I was just using "year" as shorthand for "the prefix specified by your dropdown which can be a year or some other arbitrary string".

And you haven't answered:

And do they have to be sequential, does it matter if there's the occasional gap?

-- hugh
 
OK. What I've decided to do, rather than write all this as a custom form submission script for you, is to create a new element type ('sequence') which does this. It's quite complex, as you have to create a separate table for storing the sequence numbering in, you can't just rely on looking at the last number used in your main table (otherwise if two people load the form at the same time, you'll get duplicates).

This issue of creating sequencing numbers with a prefix/suffix has been asked a lot of times over the years, so although it's more time and effort to create a new plugin than just give you some custom code, it's worth me taking a little more time and solve this issue for everyone.

I've gotten most of the code written (I've been doing it while waiting for you answers), and will start testing the new element after I've eaten some dinner. Should have something committed to github later this evening.

-- hugh
 
OK, I added a new element plugin type, 'sequence', to github.

To install it, you'll need to do a full github update (see wiki). Then do a "Discover" in J!'s extension manager, which should show "Fabrik Element - sequence". Install it, then enable it in the J! extension manager.

You'll then be able to add your "Invoice Number" element, as type 'sequence'.

Set the "Method" to "On Submit".

Set the "Affix" to ...

{invoices__prefix}-

... or whatever the full element name of your dropdown is which has the prefix you want to use.

Set "Position" to "Prefix".

Set "Start" to 1 (or 0, or whatever you want).

-- hugh
 
Hello,
I have updated following http://fabrikar.com/forums/index.php?wiki/update-from-github/.
I have 2 problems.

1.- Option "Method: On Submit" :
Affix Position: Prefix
Affix: {sales___prefix}- (the dropdown element is "sales___prefix" with 3 options: 2017, 2018, Prefactura)
Method: On Submit
Start: 1
Padding: 4
When I safe the form the page I only see a blank page.​
2.- Option "Method: On Load" :
Affix Position: Prefix
Affix: {sales___prefix}- (the dropdown element is "sales___prefix" with 3 options: 2017, 2018, Prefactura)
Method: On Load
Start: 1
Padding: 4
When I add a new entry: I see the field element FACTURA NUM ("Invoice Number" element, as type 'sequence') exactly as {sales___prefix}-0001​

Thanks

 
Fatal error: Call to undefined method PlgFabrik_ElementSequence::swapValuesForLabels() in /home/............./plugins/fabrik_element/sequence/sequence.php on line 102
 
Oh, yeah, forgot about that. You'll need to do a full github update, to pick up some changes to the Fabrik core code needed for the new plugin.

Sent from my HTC6545LVW using Tapatalk
 
I did a full github update:

1.- I downloaded fabrik-master.zip from:
Our code is housed at https://github.com/Fabrik/fabrik. We have two main branches, one for Fabrik 3.0.x and one for Fabrik 3.2.x - 3.4.x​
2.- I chosed the option Cpanel Update:
  1. Unzip the downloaded GitHub zip to you local system.
  2. Navigate to the Fabrik-fabrik-xxx folder where you see all the files and folders.
  3. Select all files and folders and create a new Zip file, (or whichever archive format you prefer).
  4. This has to be performed otherwise the files will extract to a subdirectly and your site will not get updated.
  5. Upload the NEW zip file to the root of your site (often this is the "public_html" file).
  6. Once uploaded, refresh the directory, click on the uploaded file and select extract.
  7. Delete the ZIP file if you wish.
3.- Final Github Update Steps

Thanks
 
Issues confirmed.
"on submit" is throwing the fatal error
"on load" (fix text prefix, no placeholder in my case) it's showing the correct sequence but after save the field is empty
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top