<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Auto Item Code]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=9766</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=9766&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Auto Item Code.]]></description>
		<lastBuildDate>Tue, 12 Apr 2022 13:11:46 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Auto Item Code]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=40855#p40855</link>
			<description><![CDATA[<p>Kvvaradha describes the generalized approach (making item code a reference, thus reusing existing code).&nbsp; This would be a great addition to the base, and assuming your part numbers are numeric, would be easy to implement, using the {1} definition.&nbsp; If they are not strictly numeric, you would have to add the meta code to handle those fields.</p><p>The quick and dirty approach is what I did in <a href="https://github.com/braathwaate/frontac24/blob/wwh/core/inventory/manage/items.php">my fork</a>.&nbsp; This hard codes an assumption of how item codes are formatted, and may need to changed depending on how your item codes are formatted.&nbsp; In my case, they have an alpha prefix and a numeric suffix.</p><div class="codebox"><pre><code>inventory/manage/items.php

function item_settings(&amp;$stock_id, $new_item)
{
...
if ($new_item)
    {
        $tmpCodeID=next_stock_id();
...

function numeric_offset($text) {
    preg_match(&#039;/\d/&#039;, $text, $m, PREG_OFFSET_CAPTURE);
    if (sizeof($m))
        return $m[0][1];

    // the case when there&#039;s no numbers in the string
    return strlen($text);
}

/*
    This function returns the next unused stock_id in stock_master.
    To work correctly, stock_ids should be numeric or end in a numeric.
*/
function next_stock_id() {
    $sql = &quot;SELECT max(stock_id) as max FROM &quot;.TB_PREF.&quot;stock_master&quot;;
    $result = db_query($sql, &quot;Can not find max stock_id&quot;);
    $row = db_fetch_row($result);
    if (!$row[0]) return null;
    $offset= numeric_offset($row[0]);
    $num=substr($row[0], $offset);
    if (!is_numeric($num))
    return null;
    $num += 1;
    return substr($row[0], 0, $offset) . $num;
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Braath Waate)]]></author>
			<pubDate>Tue, 12 Apr 2022 13:11:46 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=40855#p40855</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Item Code]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=40853#p40853</link>
			<description><![CDATA[<div class="quotebox"><cite>cowlas wrote:</cite><blockquote><p>How to set the header on the Sales Invoice because its alingnment is out from the top of the page. Please guide possible with the images or steps so i can adjust it accordingly.</p></blockquote></div><p> How are you cowlas? </p><p>This is actually not clear. Are you looking view_invoice.php</p><p>Or rep107.php header2.inc and doctext.inc</p><p>Hope you have the dual header options that we&nbsp; done last time.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Tue, 12 Apr 2022 12:14:11 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=40853#p40853</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Item Code]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=40852#p40852</link>
			<description><![CDATA[<div class="quotebox"><cite>fcarll wrote:</cite><blockquote><p>It would be helpful to be able to allow FA to auto increment the item code when adding new items.&nbsp; </p><p>I am switching from an accounting system that auto populated the item code.&nbsp; </p><p>Researching the forum showed that the issue was raised in 2017 but I cannot find any further reference. </p><p>Regards, Frank Carll</p></blockquote></div><p> Hope the core doesn&#039;t have this feature. You need to create constant in types.in and use it inside the sysnames.inc and update it on transactions_db.inc. after that you can see the item in transaction references. </p><p>Create one there with your desired format and customize the items.php and get next reference will help you to make it auto increment on item codes.</p>]]></description>
			<author><![CDATA[null@example.com (kvvaradha)]]></author>
			<pubDate>Tue, 12 Apr 2022 12:11:58 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=40852#p40852</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Item Code]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=40850#p40850</link>
			<description><![CDATA[<p>How to set the header on the Sales Invoice because its alingnment is out from the top of the page. Please guide possible with the images or steps so i can adjust it accordingly.</p>]]></description>
			<author><![CDATA[null@example.com (cowlas)]]></author>
			<pubDate>Tue, 12 Apr 2022 11:16:24 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=40850#p40850</guid>
		</item>
		<item>
			<title><![CDATA[Auto Item Code]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=40849#p40849</link>
			<description><![CDATA[<p>It would be helpful to be able to allow FA to auto increment the item code when adding new items.&nbsp; </p><p>I am switching from an accounting system that auto populated the item code.&nbsp; </p><p>Researching the forum showed that the issue was raised in 2017 but I cannot find any further reference. </p><p>Regards, Frank Carll</p>]]></description>
			<author><![CDATA[null@example.com (fcarll)]]></author>
			<pubDate>Tue, 12 Apr 2022 10:06:03 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=40849#p40849</guid>
		</item>
	</channel>
</rss>
