elax wrote:Probably because FA developers prefer to spend their time to add new features to FA (or fix bug or answer question on the forum) instead of fixing something which is not broken ... And if they were, they'll probably start by something else ;-)
/Elax
You are right. It'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't know how it's working. When I tried to implement it in another page, it'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't add another code at all and I've been wondering why this code works. But, when I want to change the sales group according to branch, it's not working and I still have no idea why. So, i just want to ask a very simple and below is my code:
customer_list_row(_("Customer:"), 'customer_id', null, false, true, false, true);
customer_branches_list_row(_("Branch").':', $_POST['customer_id'], 'branch_id', null, false, true, true, true);
label_row(_("Currency:"), get_customer_currency($_POST['customer_id']));
amount_row(_("Project Value").':', 'value');
$branch = get_cust_branch($_POST['customer_id'], $_POST['branch_id']);
label_row(_("Business unit:"), get_sales_group_name($branch['group_no']));
When I read the sales order ui header function, I understand the flow of the logic. But I don't know which part is affecting the change because it'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'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.
Here is my full code:
<?php
$path_to_root = "../..";
$page_security = 'SA_SALESPROJECTS';
include_once($path_to_root . "/includes/session.inc");
$js = '';
$js .= get_js_date_picker();
page(_($help_context = "Sales Projects"), false, false, "", $js);
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/sales/includes/db/sales_projects_db.inc");
simple_page_mode(true);
function can_process() {
if (strlen($_POST['project_name']) == 0) {
display_error(_("Project name can not be empty."));
set_focus('project_name');
return false;
}
if (strlen($_POST['contract_no']) == 0) {
display_error(_("Contract number can not be empty."));
set_focus('contract_no');
return false;
}
return true;
}
if ($Mode == 'ADD_ITEM' && can_process()) {
}
if ($Mode == 'UPDATE_ITEM' && can_process()) {
}
if ($Mode == 'Delete') {
}
if ($Mode == 'RESET') {
}
$result = get_all_projects(check_value('show_inactive'));
start_form();
start_table(TABLESTYLE, "width=80%");
$th = array(_('Project No'), _('Project Name'), _('Contract No'), _('Customer'), _('Branch'), _('Value'), _('Type'), '', '');
inactive_control_column($th);
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
alt_table_row_color($k);
label_cell($myrow["project_no"]);
label_cell($myrow["project_name"]);
label_cell($myrow["contract_no"]);
label_cell($myrow["name"]);
label_cell($myrow["br_name"]);
label_cell($myrow["value"]);
label_cell($myrow["project_type"]);
inactive_control_cell($myrow["project_no"], $myrow["inactive"], 'sales_projects', 'project_no');
edit_button_cell("Edit" . $myrow['project_no'], _("Edit"));
delete_button_cell("Delete" . $myrow['project_no'], _("Delete"));
end_row();
}
inactive_control_row($th);
end_table();
br();
start_table(TABLESTYLE2);
if ($selected_id != -1) {
if ($Mode == 'Edit') {
$comments = $_POST['comments'];
}
hidden('selected_id', $selected_id);
} else {
$comments = '';
}
text_row_ex(_("Project Name") . ':', 'project_name', 25);
text_row_ex(_("Contract No") . ':', 'contract_no', 25);
customer_list_row(_("Customer:"), 'customer_id', null, false, true, false, true);
customer_branches_list_row(_("Branch").':', $_POST['customer_id'], 'branch_id', null, false, true, true, true);
label_row(_("Currency:"), get_customer_currency($_POST['customer_id']));
amount_row(_("Project Value").':', 'value');
$branch = get_cust_branch($_POST['customer_id'], $_POST['branch_id']);
label_row(_("Business unit:"), get_sales_group_name($branch['group_no']));
project_type_row(_("Project Type").':','project_type');
date_row(_("Start").':', 'start_date');
date_row(_("End").':', 'end_date');
project_ref_row(_("Project Ref").':','ref_project');
textarea_row(_("Comments") . ':', 'comments',$comments, 25,3);
end_table(1);
submit_add_or_update_center($selected_id == -1, '', 'both');
end_form();
end_page();
?>