<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Salesman per sales group]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=4721</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4721&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Salesman per sales group.]]></description>
		<lastBuildDate>Wed, 05 Feb 2014 05:05:30 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Salesman per sales group]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19186#p19186</link>
			<description><![CDATA[<div class="quotebox"><cite>elax wrote:</cite><blockquote><p>Probably because FA developers prefer to spend their time to add new features to FA (or fix bug or answer question on the forum)&nbsp; instead of fixing something which is not broken ... And if they were, they&#039;ll probably start by something else ;-)</p><p>/Elax</p></blockquote></div><p>You are right. It&#039;s better to focus on fixing the bug. By the way I want to ask abou ajax again. Honsetly, the previous code is working but I don&#039;t know how it&#039;s working. When I tried to implement it in another page, it&#039;s not working. basically, I just want to do some simple change like in sales order UI. I want to create selector for customer, selector branch, info about currency, and info about sales group. When I change customer, the branch and currency is changed according the customer even though I don&#039;t add another code at all and I&#039;ve been wondering why this code works. But, when I want to change the sales group according to branch, it&#039;s not working and I still have no idea why. So, i just want to ask a very simple and below is my code: </p><div class="codebox"><pre><code>customer_list_row(_(&quot;Customer:&quot;), &#039;customer_id&#039;, null, false, true, false, true);
customer_branches_list_row(_(&quot;Branch&quot;).&#039;:&#039;, $_POST[&#039;customer_id&#039;], &#039;branch_id&#039;, null, false, true, true, true);
label_row(_(&quot;Currency:&quot;), get_customer_currency($_POST[&#039;customer_id&#039;]));
amount_row(_(&quot;Project Value&quot;).&#039;:&#039;, &#039;value&#039;);
$branch = get_cust_branch($_POST[&#039;customer_id&#039;], $_POST[&#039;branch_id&#039;]);
label_row(_(&quot;Business unit:&quot;), get_sales_group_name($branch[&#039;group_no&#039;]));</code></pre></div><br /><p>When I read the sales order ui header function, I understand the flow of the logic. But I don&#039;t know which part is affecting the change because it&#039;s so may if there. So, from code above, can you help me to explain why customer branch and currency changed when I change customer but sales group name won&#039;t change even though I change branch? I really than you if you could help me with this. The code or customer and branch is copied form sales order ui.</p><p>Here is my full code:</p><div class="codebox"><pre><code>&lt;?php

$path_to_root = &quot;../..&quot;;
$page_security = &#039;SA_SALESPROJECTS&#039;;

include_once($path_to_root . &quot;/includes/session.inc&quot;);
$js = &#039;&#039;;
$js .= get_js_date_picker();
page(_($help_context = &quot;Sales Projects&quot;), false, false, &quot;&quot;, $js);
include_once($path_to_root . &quot;/includes/ui.inc&quot;);
include_once($path_to_root . &quot;/sales/includes/db/sales_projects_db.inc&quot;);

simple_page_mode(true);

function can_process() {
    if (strlen($_POST[&#039;project_name&#039;]) == 0) {
        display_error(_(&quot;Project name can not be empty.&quot;));
        set_focus(&#039;project_name&#039;);
        return false;
    }

    if (strlen($_POST[&#039;contract_no&#039;]) == 0) {
        display_error(_(&quot;Contract number can not be empty.&quot;));
        set_focus(&#039;contract_no&#039;);
        return false;
    }
    return true;
}

if ($Mode == &#039;ADD_ITEM&#039; &amp;&amp; can_process()) {
    
}

if ($Mode == &#039;UPDATE_ITEM&#039; &amp;&amp; can_process()) {
    
}

if ($Mode == &#039;Delete&#039;) {
    
}

if ($Mode == &#039;RESET&#039;) {
    
}

$result = get_all_projects(check_value(&#039;show_inactive&#039;));

start_form();
start_table(TABLESTYLE, &quot;width=80%&quot;);

$th = array(_(&#039;Project No&#039;), _(&#039;Project Name&#039;), _(&#039;Contract No&#039;), _(&#039;Customer&#039;), _(&#039;Branch&#039;), _(&#039;Value&#039;), _(&#039;Type&#039;), &#039;&#039;, &#039;&#039;);
inactive_control_column($th);
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    label_cell($myrow[&quot;project_no&quot;]);
    label_cell($myrow[&quot;project_name&quot;]);
    label_cell($myrow[&quot;contract_no&quot;]);
    label_cell($myrow[&quot;name&quot;]);
    label_cell($myrow[&quot;br_name&quot;]);
    label_cell($myrow[&quot;value&quot;]);
    label_cell($myrow[&quot;project_type&quot;]);
    inactive_control_cell($myrow[&quot;project_no&quot;], $myrow[&quot;inactive&quot;], &#039;sales_projects&#039;, &#039;project_no&#039;);
    edit_button_cell(&quot;Edit&quot; . $myrow[&#039;project_no&#039;], _(&quot;Edit&quot;));
    delete_button_cell(&quot;Delete&quot; . $myrow[&#039;project_no&#039;], _(&quot;Delete&quot;));
    end_row();
}
inactive_control_row($th);
end_table();

br();

start_table(TABLESTYLE2);

if ($selected_id != -1) {

    if ($Mode == &#039;Edit&#039;) {
        $comments = $_POST[&#039;comments&#039;];
    }
    hidden(&#039;selected_id&#039;, $selected_id);
} else {
    $comments = &#039;&#039;;
}

text_row_ex(_(&quot;Project Name&quot;) . &#039;:&#039;, &#039;project_name&#039;, 25);
text_row_ex(_(&quot;Contract No&quot;) . &#039;:&#039;, &#039;contract_no&#039;, 25);
customer_list_row(_(&quot;Customer:&quot;), &#039;customer_id&#039;, null, false, true, false, true);
customer_branches_list_row(_(&quot;Branch&quot;).&#039;:&#039;, $_POST[&#039;customer_id&#039;], &#039;branch_id&#039;, null, false, true, true, true);
label_row(_(&quot;Currency:&quot;), get_customer_currency($_POST[&#039;customer_id&#039;]));
amount_row(_(&quot;Project Value&quot;).&#039;:&#039;, &#039;value&#039;);
$branch = get_cust_branch($_POST[&#039;customer_id&#039;], $_POST[&#039;branch_id&#039;]);
label_row(_(&quot;Business unit:&quot;), get_sales_group_name($branch[&#039;group_no&#039;]));
project_type_row(_(&quot;Project Type&quot;).&#039;:&#039;,&#039;project_type&#039;);
date_row(_(&quot;Start&quot;).&#039;:&#039;, &#039;start_date&#039;);
date_row(_(&quot;End&quot;).&#039;:&#039;, &#039;end_date&#039;);
project_ref_row(_(&quot;Project Ref&quot;).&#039;:&#039;,&#039;ref_project&#039;);
textarea_row(_(&quot;Comments&quot;) . &#039;:&#039;, &#039;comments&#039;,$comments, 25,3);
end_table(1);

submit_add_or_update_center($selected_id == -1, &#039;&#039;, &#039;both&#039;);

end_form();
end_page();
?&gt;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (barbarian)]]></author>
			<pubDate>Wed, 05 Feb 2014 05:05:30 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19186#p19186</guid>
		</item>
		<item>
			<title><![CDATA[Re: Salesman per sales group]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19177#p19177</link>
			<description><![CDATA[<p>Probably because FA developers prefer to spend their time to add new features to FA (or fix bug or answer question on the forum)&nbsp; instead of fixing something which is not broken ... And if they were, they&#039;ll probably start by something else ;-)</p><p>/Elax</p>]]></description>
			<author><![CDATA[null@example.com (elax)]]></author>
			<pubDate>Tue, 04 Feb 2014 16:52:45 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19177#p19177</guid>
		</item>
		<item>
			<title><![CDATA[Re: Salesman per sales group]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19174#p19174</link>
			<description><![CDATA[<p>By the way, why FA don&#039;t use jquery for ajax? I think it&#039;s easier and JsHttpRequest is already old (was made in2006, http://en.dklab.ru/lib/JsHttpRequest/).</p>]]></description>
			<author><![CDATA[null@example.com (barbarian)]]></author>
			<pubDate>Tue, 04 Feb 2014 15:22:44 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19174#p19174</guid>
		</item>
		<item>
			<title><![CDATA[Re: Salesman per sales group]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19173#p19173</link>
			<description><![CDATA[<div class="quotebox"><cite>joe wrote:</cite><blockquote><p>There is no manual on how to use the ajax in FA.</p><p>To make it simple please have a look in /sales/includes/ui/sales_order_ui.inc</p><p>Look up the function display_order_header, line 258.</p><p>First in the function the $Ajax is defined as global.</p><p>$Ajax-&gt;update($name) can be used either for a single Control (the Control name) or a span of code with div_start($name) and div_end(), where you can declare your own name and use it in $Ajax-&gt;update.</p><p>Everytime the $Ajax-&gt;update is called the specific Control/code is called.</p><p>By looking at the code here, I guess you will get a first hint of how to use it.</p><p>/Joe</p></blockquote></div><br /><br /><p>Thank you for your answer. I think this is the code :</p><p>&nbsp; &nbsp; &nbsp; &nbsp;customer_list_row(_(&quot;Customer:&quot;), &#039;customer_id&#039;, null, false, true, false, true);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; if ($order-&gt;customer_id != get_post(&#039;customer_id&#039;, -1)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // customer has changed<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $Ajax-&gt;activate(&#039;branch_id&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; customer_branches_list_row(_(&quot;Branch:&quot;), $_POST[&#039;customer_id&#039;], &#039;branch_id&#039;, null, false, true, true, true);</p><br /><p>I don&#039;t know why, but, if I delete the if part, it still working. The code below still works like the code above. Do you know why?<br />&nbsp; &nbsp; &nbsp; &nbsp;customer_list_row(_(&quot;Customer:&quot;), &#039;customer_id&#039;, null, false, true, false, true);<br />&nbsp; &nbsp; &nbsp; &nbsp;customer_branches_list_row(_(&quot;Branch:&quot;), $_POST[&#039;customer_id&#039;], &#039;branch_id&#039;, null, false, true, true, true);</p><br /><p>And by the way, I already successfully created my modification of salesman per sales group. The issue is not the ajax, but the if part that trigger the ajax event.</p>]]></description>
			<author><![CDATA[null@example.com (barbarian)]]></author>
			<pubDate>Tue, 04 Feb 2014 15:17:49 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19173#p19173</guid>
		</item>
		<item>
			<title><![CDATA[Re: Salesman per sales group]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19172#p19172</link>
			<description><![CDATA[<p>There is no manual on how to use the ajax in FA.</p><p>To make it simple please have a look in /sales/includes/ui/sales_order_ui.inc</p><p>Look up the function display_order_header, line 258.</p><p>First in the function the $Ajax is defined as global.</p><p>$Ajax-&gt;update($name) can be used either for a single Control (the Control name) or a span of code with div_start($name) and div_end(), where you can declare your own name and use it in $Ajax-&gt;update.</p><p>Everytime the $Ajax-&gt;update is called the specific Control/code is called.</p><p>By looking at the code here, I guess you will get a first hint of how to use it.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Tue, 04 Feb 2014 14:59:26 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19172#p19172</guid>
		</item>
		<item>
			<title><![CDATA[Salesman per sales group]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19170#p19170</link>
			<description><![CDATA[<p>Hello,</p><p>I&#039;ve been desperate with ajax in Frontaccounting, but my question in another thread is not answered. I don&#039;t know if there is no one who understand or no one whol willing to share their knowledge. Anyway, I&#039;m just try to ask agan. I hope someone will give some of their knowledge or I must find another application that easier to modified.</p><p>What I want to modify is basically simple. I want to create some dropdown which has another dropdown as the parent. It&#039;s exactly like customer and branch dropdown in sales order entry. I want to create this with sales group and salesman. I already modified that a salesman has only one sales group. In customer branch, I want to add this dropdown function. I have already modified the UI for displaying the dropdown in sales group so that it has submit on change. I saw another example that use Ajax-&gt;activate. But nothing happen. I don&#039;t know what I must do because there is no clue and I cannot debug with my code inspector because the post in header is very difficult to understand. Anyone can help?</p>]]></description>
			<author><![CDATA[null@example.com (barbarian)]]></author>
			<pubDate>Tue, 04 Feb 2014 14:09:47 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19170#p19170</guid>
		</item>
	</channel>
</rss>
