<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Auto Item Code]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=9766&amp;type=atom" />
	<updated>2022-04-12T13:11:46Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=9766</id>
		<entry>
			<title type="html"><![CDATA[Re: Auto Item Code]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=40855#p40855" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Braath Waate]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=41493</uri>
			</author>
			<updated>2022-04-12T13:11:46Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=40855#p40855</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Auto Item Code]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=40853#p40853" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2022-04-12T12:14:11Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=40853#p40853</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Auto Item Code]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=40852#p40852" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2022-04-12T12:11:58Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=40852#p40852</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Auto Item Code]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=40850#p40850" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[cowlas]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=42123</uri>
			</author>
			<updated>2022-04-12T11:16:24Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=40850#p40850</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Auto Item Code]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=40849#p40849" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[fcarll]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=46447</uri>
			</author>
			<updated>2022-04-12T10:06:03Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=40849#p40849</id>
		</entry>
</feed>
