<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — function customer_list_low]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=10650&amp;type=atom" />
	<updated>2025-04-17T15:46:13Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=10650</id>
		<entry>
			<title type="html"><![CDATA[Re: function customer_list_low]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=43607#p43607" />
			<content type="html"><![CDATA[<p>Yes, db_fetch() function used in list helper functions returns data array indexed both associative and numerically. So it can lead to some problems depending on code processing the result. As far as I know this is not the case with FA base code.</p><p>Regarding blank string (&quot; &quot;) used as fourth argument in customer_list_row(), it is intentional in some places, just to have unnamed special option, which could be read just as &#039;not applicable&#039;. E.g. in recurrent invoices it is special case of recurrent invoice defined for whole sales group, not individual customer.</p><p>J.</p>]]></content>
			<author>
				<name><![CDATA[janusz]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=4693</uri>
			</author>
			<updated>2025-04-17T15:46:13Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=43607#p43607</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: function customer_list_low]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=43603#p43603" />
			<content type="html"><![CDATA[<p>I guess I will ask janusz to look into this. He wrote these routines, i.e. customer_list_row. Combined with search functions.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2025-04-17T10:14:22Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=43603#p43603</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: function customer_list_low]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=43597#p43597" />
			<content type="html"><![CDATA[<p>Very good troubleshooting.<br />Kudos @trafficpest.</p><p>@joe: are there any other scripts that will benefit from this?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2025-04-15T18:56:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=43597#p43597</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: function customer_list_low]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=43596#p43596" />
			<content type="html"><![CDATA[<p><strong>SOLVED: Customer Dropdown Showing Two Selected Options on Edit</strong></p><p><strong>Problem:</strong> When editing a record, the customer dropdown (`debtor_no`) was incorrectly showing two selected customers. The correct customer ID for the record was present in the `$_POST` data, but the dropdown also selected the record&#039;s primary key ID.</p><p><strong>Cause:</strong> The issue stemmed from how the `$_POST` array was populated during the edit operation. Instead of explicitly setting each form field value from the fetched database row (`$myrow`) to its corresponding associative key in `$_POST`, the entire `$myrow` array was directly assigned to `$_POST`. This resulted in `$_POST` containing both associative keys (column names) and numerical indexes (based on the order of columns fetched).</p><p>The `combo_input` function, used to generate the dropdown, was likely accessing the `$_POST` array and inadvertently picking up the value at index `0` (which was the record&#039;s primary key `id`) in addition to the correct `debtor_no`. This led to both IDs being included in the `$selected_id` array processed by `combo_input`, causing both options to be marked as `selected` in the HTML.</p><p><strong>Fix:</strong> To resolve this, ensure that you explicitly set each relevant form field value in the `$_POST` array using the associative keys from your fetched database row.</p><p><strong>Incorrect (Causing the Issue):</strong><br /></p><div class="codebox"><pre><code>$_POST = $myrow;</code></pre></div><p>ie. Don&#039;t be lazy like me</p><p><strong>Correct (Explicitly Setting Values):</strong><br /></p><div class="codebox"><pre><code>$_POST[&#039;debtor_no&#039;] = $myrow[&#039;debtor_no&#039;];
$_POST[&#039;other_field&#039;] = $myrow[&#039;other_field&#039;];
// ... and so on for all your form fields</code></pre></div><p>By explicitly assigning the values, you prevent the numerical indexes from being present in the `$_POST` array and thus avoid the `combo_input` function mistakenly selecting the record&#039;s primary key ID.</p>]]></content>
			<author>
				<name><![CDATA[trafficpest]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=42061</uri>
			</author>
			<updated>2025-04-15T17:22:27Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=43596#p43596</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: function customer_list_low]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=43592#p43592" />
			<content type="html"><![CDATA[<p>Yeah I was looking over and noticed the 3rd example</p><p>Line 195 in sales/manage/recurrent_invoices.php</p><p>customer_list_row(_(&quot;Customer:&quot;), &#039;debtor_no&#039;, null, &quot; &quot;, true);</p><p>I was wondering why the space for 3rd arg. It should become true since it has a space but strange.</p><p>I&#039;m going to look it over tomorrow there has to be something I&#039;m missing, maybe I&#039;ll try another browser. So strange that the generated source has the correct id as selected. Maybe it&#039;s a time / buffer issue.</p>]]></content>
			<author>
				<name><![CDATA[trafficpest]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=42061</uri>
			</author>
			<updated>2025-04-15T08:20:49Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=43592#p43592</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: function customer_list_low]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=43588#p43588" />
			<content type="html"><![CDATA[<p>Here is how it is called elsewhere:<br />Line 64 in <strong>gl/includes/ui/gl_bank_ui.inc</strong><br /></p><div class="codebox"><pre><code>customer_list_row(_(&quot;Customer:&quot;), &#039;person_id&#039;, null, false, true, false, true);</code></pre></div><p>Line 29 in <strong>sales/includes/ui/sales_credit_ui.inc</strong> and Line 267 in <strong>sales/includes/ui/sales_order_ui.inc</strong><br /></p><div class="codebox"><pre><code>customer_list_row(_(&quot;Customer:&quot;), &#039;customer_id&#039;, null, false, true, false, true);</code></pre></div><p>Line 195 in <strong>sales/manage/recurrent_invoices.php</strong><br /></p><div class="codebox"><pre><code>customer_list_row(_(&quot;Customer:&quot;), &#039;debtor_no&#039;, null, &quot; &quot;, true);</code></pre></div><p>Check the 2nd and 3rd arguments in your construct. You can try to use an intermediary variable for the <strong>isset()</strong> argument.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2025-04-15T06:39:23Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=43588#p43588</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[function customer_list_low]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=43586#p43586" />
			<content type="html"><![CDATA[<p>I have an issue with customer list row that is strange I don&#039;t think there is an issue in the function. I don&#039;t know what is going on.</p><p>This is how I&#039;m calling it:<br /></p><div class="codebox"><pre><code>customer_list_row(_(&quot;Customer:&quot;), &#039;debtor_no&#039;, isset($_POST[&#039;debtor_no&#039;]) ? $_POST[&#039;debtor_no&#039;] : null, false, true);</code></pre></div><p>I&#039;m having an issue with selected_id for editing a form. I have tried manually entering a client as int 3 and string &#039;3&#039; also null since I&#039;m passing update. But, it is not showing selected in the browser. It is giving me a random one. the strangest thing is it shows selected in the source and chrome inspector. have you seen anything like this before? my branch_list is working correctly below it. I have the form wrapped in a div for ajax for a few buttons and everything is working fine there.</p>]]></content>
			<author>
				<name><![CDATA[trafficpest]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=42061</uri>
			</author>
			<updated>2025-04-14T21:27:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=43586#p43586</id>
		</entry>
</feed>
