Jump to content
Server Maintenance This Week. ×

Auto generate next number


This topic is 4931 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello,

I need to make a function (or script) that will auto generate the next order number for me.

first 4 numbers:

the first 4 numbers are unique.

every order has to get a unique (next in line) number. 0001, 0002, 0003 and so on.

I dont wont it to have 'wholes' like 0001, 0003, 0004 because someone started to make 0002 and deleted it before commiting, so it has to check what was the last number that started with 0 (because we have old orders that start with 2010) and do a +1.

the 2nd part is also 4 numbers:

these numbers are given by us (client number)

and the last 2 numbers are shipment numbers.

this also has to check if the client already has an order and get the last shipment number and do a +1

so it should look like this:

0001-2222-01

0002-2233-01

0003-2222-02

0004-2222-03

0005-3333-01

0006-2233-02

0007-2222-04

I was thinking the function should be something like genOrder(client)

Anyone who can help making this effecient and bug free? thanx in advance!

Edited by Guest
Link to comment
Share on other sites

This topic is 4931 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.