From: Janusz Dobrowolski Date: Thu, 18 Sep 2008 19:45:10 +0000 (+0000) Subject: Add/view on F4 in customer selector. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=da61be68a763e80173f92b54cd5a06446f3ac58e;p=textcart.git Add/view on F4 in customer selector. --- diff --git a/sales/allocations/customer_allocation_main.php b/sales/allocations/customer_allocation_main.php index b0c6725..4c9e5a5 100644 --- a/sales/allocations/customer_allocation_main.php +++ b/sales/allocations/customer_allocation_main.php @@ -12,6 +12,13 @@ if ($use_popup_windows) page(_("Customer Allocations"), false, false, "", $js); //-------------------------------------------------------------------------------- +if ($ret = context_restore()) { + if(isset($ret['customer_id'])) + $_POST['customer_id'] = $ret['customer_id']; +} +if (isset($_POST['_customer_id_editor'])) { + context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'] ); +} function display_allocatable_transactions() { diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index 9a73d7c..89a1cf0 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -40,6 +40,18 @@ check_db_has_stock_items(_("There are no items defined in the system.")); check_db_has_customer_branches(_("There are no customers, or there are no customers with branches. Please define customers and customer branches.")); //----------------------------------------------------------------------------- +if ($ret = context_restore()) { + // return from new customer add + copy_from_cn(); + if(isset($ret['customer_id'])) + $_POST['customer_id'] = $ret['customer_id']; + if(isset($ret['branch_id'])) + $_POST['branch_id'] = $ret['branch_id']; +} +if (isset($_POST['_customer_id_editor'])) { + copy_to_cn(); //store context + context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'], 'Items'); +} if (isset($_GET['AddedID'])) { $credit_no = $_GET['AddedID']; @@ -96,7 +108,6 @@ function handle_new_credit($trans_no) processing_start(); $_SESSION['Items'] = new Cart(11,$trans_no); copy_from_cn(); - line_start_focus(); } //----------------------------------------------------------------------------- diff --git a/sales/customer_payments.php b/sales/customer_payments.php index c93db3a..42cb552 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -27,6 +27,17 @@ check_db_has_bank_accounts(_("There are no bank accounts defined in the system." check_db_has_bank_trans_types(_("There are no bank payment types defined in the system.")); //---------------------------------------------------------------------------------------- +if ($ret = context_restore()) { + if(isset($ret['customer_id'])) + $_POST['customer_id'] = $ret['customer_id']; + if(isset($ret['branch_id'])) + $_POST['BranchID'] = $ret['branch_id']; +} +if (isset($_POST['_customer_id_editor'])) { + context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'], + array( 'customer_id', 'BranchID', 'bank_account', 'DateBanked', + 'ReceiptType', 'ref', 'amount', 'discount', 'memo_') ); +} if (isset($_GET['AddedID'])) { $payment_no = $_GET['AddedID']; @@ -101,7 +112,7 @@ if (isset($_POST['AddPaymentItem'])) { } if (isset($_POST['_customer_id_button'])) { // unset($_POST['branch_id']); - $Ajax->activate('branch_id'); + $Ajax->activate('BranchID'); } //---------------------------------------------------------------------------------------------- diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index 1b9db8f..16e8fd4 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -22,15 +22,7 @@ function display_credit_header(&$order) if ($order->customer_id != $_POST['customer_id'] /*|| $order->sales_type != $_POST['sales_type_id']*/) { // customer has changed - - // delete all the order items - drastic but necessary because of - // change of currency, sales type, etc -// $order->clear_items(); - - // clear the branch selection -// unset($_POST['branch_id']); - $_POST['branch_id'] = ''; - $Ajax->activate('branch_id'); + $Ajax->activate('branch_id'); } customer_branches_list_row(_("Branch:"), $_POST['customer_id'], @@ -62,7 +54,7 @@ function display_credit_header(&$order) } if ($old_order->sales_type != $order->sales_type) { // || $old_order->default_discount!=$order->default_discount - $_POST['sales_type'] = $order->sales_type; + $_POST['sales_type_id'] = $order->sales_type; $Ajax->activate('sales_type_id'); $change_prices = 1; } diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index b4fcc7d..ec18830 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -177,8 +177,6 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group if ($order->customer_id != get_post('customer_id', -1)) { // customer has changed - // clear the branch selection - $_POST['branch_id'] = ''; $Ajax->activate('branch_id'); } customer_branches_list_row(_("Branch:"), diff --git a/sales/manage/customer_branches.php b/sales/manage/customer_branches.php index 30669de..c4460d6 100644 --- a/sales/manage/customer_branches.php +++ b/sales/manage/customer_branches.php @@ -35,6 +35,13 @@ if (isset($_GET['SelectedBranch'])) $selected_id = $_GET['SelectedBranch']; } +$id = find_submit('Select'); +if ($id != -1) +{ + context_return(array('customer_id' => $_POST['customer_id'], + 'branch_id' => $id)); // return to sales document +} + //----------------------------------------------------------------------------------------------- if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') @@ -179,6 +186,7 @@ if ($num_branches) $th = array(_("Name"), _("Contact"), _("Sales Person"), _("Area"), _("Phone No"), _("Fax No"), _("E-mail"), _("Tax Group"), "", ""); + if (count($_SESSION['Context'])) $th[] = ''; table_header($th); while ($myrow = db_fetch($result)) @@ -192,6 +200,8 @@ if ($num_branches) label_cell($myrow["fax"]); label_cell("" . $myrow["email"]. ""); label_cell($myrow["tax_group_name"]); + if (count($_SESSION['Context'])) + edit_button_cell("Select".$myrow["branch_code"], _("Select")); edit_button_cell("Edit".$myrow["branch_code"], _("Edit")); edit_button_cell("Delete".$myrow["branch_code"], _("Delete")); end_row(); diff --git a/sales/manage/customers.php b/sales/manage/customers.php index bf58e76..f33ad97 100644 --- a/sales/manage/customers.php +++ b/sales/manage/customers.php @@ -10,6 +10,10 @@ include_once($path_to_root . "/includes/date_functions.inc"); 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'] == ""); //-------------------------------------------------------------------------------------------- @@ -18,24 +22,28 @@ function can_process() 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; } @@ -97,15 +105,18 @@ function handle_submit() $Ajax->activate('_page_body'); } } - //-------------------------------------------------------------------------------------------- if (isset($_POST['submit'])) { - handle_submit(); } +//-------------------------------------------------------------------------------------------- +if (isset($_POST['select'])) +{ + context_return(array('customer_id' => $_POST['customer_id'])); // return to sales document +} //-------------------------------------------------------------------------------------------- if (isset($_POST['delete'])) @@ -161,7 +172,6 @@ if (isset($_POST['delete'])) } //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(); @@ -261,10 +271,10 @@ amount_row(_("Credit Limit:"), 'credit_limit', $_POST['credit_limit']); 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(); - echo ''._('Customer branches').':'; - hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php",''. _("Add or Edit").'', "debtor_no=".$_POST['customer_id']); -end_row(); + start_row(); + echo ''._('Customer branches').':'; + hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php",''. (count($_SESSION['Context']) ? _("Select or Add") : _("Add or Edit")).'', "debtor_no=".$_POST['customer_id']); + end_row(); } end_table(); @@ -278,6 +288,7 @@ else { 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 customer data if have been never used'), true); } diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index 8c3eb66..2113662 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -18,6 +18,19 @@ include_once($path_to_root . "/sales/includes/db/sales_types_db.inc"); include_once($path_to_root . "/reporting/includes/reporting.inc"); $js = ''; +if ($ret = context_restore()) { + // return from new customer add + copy_from_cart(); + if(isset($ret['customer_id'])) + $_POST['customer_id'] = $ret['customer_id']; + if(isset($ret['branch_id'])) + $_POST['branch_id'] = $ret['branch_id']; +} +if (isset($_POST['_customer_id_editor'])) { + copy_to_cart(); //store context + context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'], 'Items'); +} + if ($use_popup_windows) { $js .= get_js_open_window(900, 500); }