<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Validate fields: sales_order_entry.php modification]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4556&amp;type=atom" />
	<updated>2013-12-08T10:03:07Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=4556</id>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18699#p18699" />
			<content type="html"><![CDATA[<p>Instead of hidden names in the form, why not lookup the names from the db in the processing code?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2013-12-08T10:03:07Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18699#p18699</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18680#p18680" />
			<content type="html"><![CDATA[<p>Hi all,</p><p>I&#039;m still working to solve this problem on my own. I used the var_dump() to investigate why the code above was not working and discovered that the obvious reasons why it did not work.</p><p>The $_POST array contained branch_id as an integer and the dimension_id was also an integer but with a different value from the branch_id. Invariably, there won&#039;t be a match.</p><p>My proposed solution is to compare the branch and dimension names (strings) within database instead of the id(s) by introducing hidden fields for the names within the form and matching them together.</p><p>My question is how do i make hidden fields within the direct invoice form in FA. I am previously used to html tags, it seems FA makes use of a different convention i am yet to fully understand. So pls i really need help on this.</p><p>Secondly, what other scripts will require modification for the solution to work?</p><p>Thanks.</p>]]></content>
			<author>
				<name><![CDATA[topekenneth]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18768</uri>
			</author>
			<updated>2013-12-05T15:22:49Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18680#p18680</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18596#p18596" />
			<content type="html"><![CDATA[<p>Hi tm,</p><p>I see what you are trying to point out now. I actually tried that earlier and it did not work. I just copied your code and it still did not work.</p><p>I appreciate your help this far, but can you help me fix this for good pls?</p><p>Thanks</p>]]></content>
			<author>
				<name><![CDATA[topekenneth]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18768</uri>
			</author>
			<updated>2013-11-28T13:40:00Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18596#p18596</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18595#p18595" />
			<content type="html"><![CDATA[<p>Fair enough. Removing the space, your code becomes:</p><p>&nbsp; &nbsp; $match = get_post (&#039;dimension_id&#039;);<br />&nbsp; &nbsp; $match = preg_replace (&#039;/^\d+\s+/&#039;, &#039;&#039;, $match);<br />&nbsp; &nbsp; if (get_post(&#039;branch_id&#039;) != $match)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; display_error(_(&quot;The Branch does not match the Dimension chosen.&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; set_focus (&#039;dimension_id&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; return false;<br />&nbsp; &nbsp; }</p><p>See if that works.</p>]]></content>
			<author>
				<name><![CDATA[tm]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=17873</uri>
			</author>
			<updated>2013-11-28T13:27:37Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18595#p18595</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18594#p18594" />
			<content type="html"><![CDATA[<p>Hi tm,</p><p>I&#039;m not really an expert in this stuff called php. I would appreciate if someone just corrected this code for me. Thanks. Want to ensure the branch chosen is the same with the dimension.</p>]]></content>
			<author>
				<name><![CDATA[topekenneth]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18768</uri>
			</author>
			<updated>2013-11-28T13:09:20Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18594#p18594</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18593#p18593" />
			<content type="html"><![CDATA[<p>The obvious problem with that code is that you are replacing the matched section with a space, rather than an empty string.</p>]]></content>
			<author>
				<name><![CDATA[tm]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=17873</uri>
			</author>
			<updated>2013-11-28T13:00:07Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18593#p18593</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18592#p18592" />
			<content type="html"><![CDATA[<p>Hi,</p><p>Thanks for your reply. I have tried what you suggested but have not gotten a breakthrough yet. here is the piece of code i added, i&#039;m not sure if i did the right thing;</p><p>}<br />&nbsp; &nbsp; $match = get_post (&#039;dimension_id&#039;);<br />&nbsp; &nbsp; $match = preg_replace (&#039;/^\d+\s+/&#039;, &#039; &#039;, $match);<br />&nbsp; &nbsp; if (get_post(&#039;branch_id&#039;) != $match)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; display_error(_(&quot;The Branch does not match the Dimension chosen.&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; set_focus (&#039;dimension_id&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; return false;<br />&nbsp; &nbsp; }</p><p>please can someone check to see what i am not getting right with sample please. Thanks</p>]]></content>
			<author>
				<name><![CDATA[topekenneth]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18768</uri>
			</author>
			<updated>2013-11-28T10:43:19Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18592#p18592</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18588#p18588" />
			<content type="html"><![CDATA[<p>If it&#039;s just a number followed by a space followed by the string you want to match, I would suggest a regex. </p><p>Substr() will fail when you get more than 9 (or 99 and so on) branches/dimensions, and the branch name moves further right in the string.</p><p>So just strip off something like [0-9]+\s+ (any number of digits followed by any amount of whitespace) from the start of the dimension string before comparing it to the branch string.</p>]]></content>
			<author>
				<name><![CDATA[tm]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=17873</uri>
			</author>
			<updated>2013-11-27T18:33:25Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18588#p18588</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Validate fields: sales_order_entry.php modification]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=18587#p18587" />
			<content type="html"><![CDATA[<p>Hi,</p><p>We want to ensure in our direct invoice entry that the customer branch and dimension selected by the users match. This is very crucial for our set up as we do not want users posting wrongly.</p><p>Here is the code i have included in the sale_order_entry.php file.</p><p>if (get_post (&#039;branch_id&#039;) != get_post(&#039;dimension_id&#039;))<br />{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;display_error(_(&quot;The branch does not match the dimension chosen.&quot;));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;set_focus (&#039;dimension_id&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return false;<br />}</p><p>The problem is that the dimension field options contains the IDs of the dimensions themselves. e.g. 1 Brisbane, 2 London etc. while the branches are Brisbane, London etc.</p><p>So every time an entry is made, the error &quot;The branch does not match the dimension chosen.&quot; appears because of the number IDs that appear with the dimensions. i have tried the substr() but have not had luck.</p><br /><p>Please i need help in ensuring that these two fields match and the effective way to do that is to warn the user before the invoice is posted.</p><p>Help is urgently needed. Thanks.</p>]]></content>
			<author>
				<name><![CDATA[topekenneth]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=18768</uri>
			</author>
			<updated>2013-11-27T14:07:02Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=18587#p18587</id>
		</entry>
</feed>
