Post Reply 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
autoincrement item code
10-23-2016, 09:20 PM
Post: #11
RE: autoincrement item code
There are not many steps involved. Firstly you need to create a new entry in the systypes database table for "Auto Inventory Number". I chose 700 as this is consistent with "Auto Debtor Number" and "Auto Supplier Number". The SQL code for this is: INSERT INTO systypes VALUES(700, 'Auto Inventory Number', 0);

Then we need to create an entry in the config table for a flag to indicate whether the inventory code are automatically generated or not : INSERT INTO config VALUES('AutoInventoryNo', 1); where 1 will signify to automatically generate the inventory code and 0 for manual entry.

Then in Stocks.php change line 134 to read
if (mb_strlen($StockId) == 0 and $_SESSION['AutoInventoryNo'] == 0) {
so that it will accept an empty stock code if it is set to auto generate them.
Then at line 611 we need to get the next available stock code by inserting this code:
if ($_SESSION['AutoInventoryNo'] == 1) {
$StockId = GetNextTransNo(700);
Finally at line 916 we need the following code:
if ($_SESSION['AutoInventoryNo'] == 0) {
echo '<tr>
<td>' . _('Item Code') . ':</td>
<td><input type="text" value="' . $StockId . '" name="StockID" size="21" required="required" maxlength="20" /></td>
} else {
echo '<tr>
<td>' . _('Item Code') . ':</td>
This will hide the stock code input box when the codes are automatically generated.

We should also change SystemParameters.php so that the flag can be set via the interface. You can just copy the code for the AutoSupplierNo flag, just altering the variable names.

This works for me, any problems just shout,
Visit this user's website Find all posts by this user
Quote this message in a reply
01-12-2017, 08:06 AM
Post: #12
RE: autoincrement item code
Find all posts by this user
Quote this message in a reply
Post Reply 

Forum Jump:

User(s) browsing this thread: 1 Guest(s)