Add/view on F4 in customer selector.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 18 Sep 2008 19:45:10 +0000 (19:45 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 18 Sep 2008 19:45:10 +0000 (19:45 +0000)
sales/allocations/customer_allocation_main.php
sales/credit_note_entry.php
sales/customer_payments.php
sales/includes/ui/sales_credit_ui.inc
sales/includes/ui/sales_order_ui.inc
sales/manage/customer_branches.php
sales/manage/customers.php
sales/sales_order_entry.php

index b0c67256423967e3397f0b739b655d5484cf311e..4c9e5a5039d5b40def0ce0c01d5dc8260594a4ee 100644 (file)
@@ -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()
 {
index 9a73d7c25c8c71ad715280e9030a1924c23bfa32..89a1cf05361d501dce5721001bb9437ef3f2dac1 100644 (file)
@@ -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();
 }
 
 //-----------------------------------------------------------------------------
index c93db3a1a704ae1a20da8336d48ef718764194e0..42cb552d8a39bd10a1c61d2df344194b28933fdd 100644 (file)
@@ -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');
 }
 //----------------------------------------------------------------------------------------------
 
index 1b9db8f10659fbeef88cfd5464118d138fcbdbe9..16e8fd488ef45fbf7aa93b3c8ec6530d4532e39d 100644 (file)
@@ -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;
                                }
index b4fcc7d4d4b8b67b6f605c37ca3691c076f078f9..ec188302813bd85e08c52e41448c2cfe24cd5128 100644 (file)
@@ -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:"),
index 30669dea720ba463794215623ce152cd88a78ea4..c4460d69e713b64569191e0a7daf8d67476117d1 100644 (file)
@@ -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("<a href=mailto:" . $myrow["email"]. ">" . $myrow["email"]. "</a>");
                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();
index bf58e7616c0a00487b4af5f87941573ae057e8c8..f33ad979332c06ef952613bda969acf1dd0cca4f 100644 (file)
@@ -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 '<td>'._('Customer branches').':</td>';
-  hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php",'<b>'. _("Add or Edit").'</b>', "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();
 
@@ -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);
 }
index 8c3eb66d32807d41f7f754b1b4ce18461241869b..211366261424caa503de8a012d5831e6feeb2aa2 100644 (file)
@@ -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);
 }