include_once($path_to_root . "/includes/banking.inc");
include_once($path_to_root . "/includes/ui.inc");
+if (isset($_GET['debtor_no']))
+{
+ $_POST['customer_id'] = $_GET['debtor_no'];
+}
$new_customer = (!isset($_POST['customer_id']) || $_POST['customer_id'] == "");
//--------------------------------------------------------------------------------------------
if (strlen($_POST['CustName']) == 0)
{
display_error(_("The customer name cannot be empty."));
+ set_focus('CustName');
return false;
}
if (!check_num('credit_limit', 0))
{
display_error(_("The credit limit must be numeric and not less than zero."));
+ set_focus('credit_limit');
return false;
}
if (!check_num('pymt_discount', 0, 100))
{
display_error(_("The payment discount must be numeric and is expected to be less than 100% and greater than or equal to 0."));
+ set_focus('pymt_discount');
return false;
}
if (!check_num('discount', 0, 100))
{
display_error(_("The discount percentage must be numeric and is expected to be less than 100% and greater than or equal to 0."));
+ set_focus('discount');
return false;
}
db_query($sql,"The customer could not be updated");
display_notification(_("Customer has been updated."));
-
}
else
{ //it is a new customer
begin_transaction();
$sql = "INSERT INTO ".TB_PREF."debtors_master (name, address, tax_id, email, dimension_id, dimension2_id,
- curr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit,
+ curr_code, credit_status, payment_terms, discount, pymt_discount,credit_limit,
sales_type) VALUES (".db_escape($_POST['CustName']) .", "
.db_escape($_POST['address']) . ", " . db_escape($_POST['tax_id']) . ","
.db_escape($_POST['email']) . ", ".db_escape($_POST['dimension_id']) . ", "
$Ajax->activate('_page_body');
}
}
-
//--------------------------------------------------------------------------------------------
if (isset($_POST['submit']))
{
-
handle_submit();
}
+//--------------------------------------------------------------------------------------------
+if (isset($_POST['select']))
+{
+ context_return(array('customer_id' => $_POST['customer_id'],
+ 'branch_id' => '')); // this fires customer history checks
+}
//--------------------------------------------------------------------------------------------
if (isset($_POST['delete']))
unset($_POST['customer_id']);
$new_customer = true;
$Ajax->activate('_page_body');
-// meta_forward($_SERVER['PHP_SELF']);
} //end if Delete Customer
}
-
check_db_has_sales_types(_("There are no sales types defined. Please define at least one sales type before adding a customer."));
start_form();
}
else
{
- hidden('customer_id', $_POST['customer_id']);
+ hidden('customer_id');
}
start_table($table_style2, 7, 6);
payment_terms_list_row(_("Payment Terms:"), 'payment_terms', $_POST['payment_terms']);
credit_status_list_row(_("Credit Status:"), 'credit_status', $_POST['credit_status']);
if (!$new_customer) {
-start_row();
- hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php", _("Edit customer branches"), "debtor_no=".$_POST['customer_id']);
-end_row();
+ start_row();
+ echo '<td>'._('Customer branches').':</td>';
+ hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php",
+ '<b>'. (count($_SESSION['Context']) ? _("Select or &Add") : _("&Add or Edit ")).'</b>',
+ "debtor_no=".$_POST['customer_id']);
+ end_row();
}
end_table();
end_table(1); // outer table
-
+div_start('controls');
if ($new_customer)
{
submit_center('submit', _("Add New Customer"), true, '', true);
{
submit_center_first('submit', _("Update Customer"),
_('Update customer data'), true);
+ submit_return('select', _("Return"), _("Select this customer and return to document entry."), true);
submit_center_last('delete', _("Delete Customer"),
- _('Delete user data if have been never used'), true);
+ _('Delete customer data if have been never used'), true);
}
-
+div_end();
end_form();
end_page();