Switch to new access levels system
[fa-stable.git] / sales / customer_payments.php
index 8ef48c17f92e4d2d9e41394c26e89efaf1889e70..ca2fcf6243ca7f244d7fc462024c0ada18962678 100644 (file)
@@ -9,8 +9,8 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-$path_to_root="..";
-$page_security = 3;
+$page_security = 'SA_SALESPAYMNT';
+$path_to_root = "..";
 include_once($path_to_root . "/includes/ui/allocation_cart.inc");
 include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/includes/date_functions.inc");
@@ -38,16 +38,12 @@ check_db_has_customers(_("There are no customers defined in the system."));
 check_db_has_bank_accounts(_("There are no bank accounts 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', 
-                       'ref', 'amount', 'discount', 'memo_') );
+
+if (list_updated('BranchID')) {
+       // when branch is selected via external editor also customer can change
+       $br = get_branch(get_post('BranchID'));
+       $_POST['customer_id'] = $br['debtor_no'];
+       $Ajax->activate('customer_id');
 }
 
 if (!isset($_POST['customer_id']))
@@ -242,11 +238,12 @@ start_form();
 
 
 
+               $comp_currency = get_company_currency();
                $cust_currency = get_customer_currency($_POST['customer_id']);
                $bank_currency = get_bank_account_currency($_POST['bank_account']);
 
                if ($cust_currency != $bank_currency) {
-                       exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], true);
+                       exchange_rate_display($bank_currency, $cust_currency, $_POST['DateBanked'], ($bank_currency == $comp_currency));
                }
 
                amount_row(_("Bank Charge:"), 'charge');