Customer Payment, Supplier Payment: early discount support.
[fa-stable.git] / sales / allocations / customer_allocate.php
index f269ca4b1a5f674bc70eb916825df83c21f9edb5..50e9d6e6b23afb26e1297e917faa3a9e9729b870 100644 (file)
@@ -17,10 +17,9 @@ include_once($path_to_root . "/includes/session.inc");
 include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/sales/includes/sales_ui.inc");
 include_once($path_to_root . "/sales/includes/sales_db.inc");
-//include_once($path_to_root . "/sales/includes/ui/cust_alloc_ui.inc");
 
 $js = "";
-if ($use_popup_windows)
+if ($SysPrefs->use_popup_windows)
        $js .= get_js_open_window(900, 500);
 
 add_js_file('allocate.js');
@@ -46,21 +45,25 @@ function edit_allocations_for_transaction($type, $trans_no)
        global $systypes_array;
 
        $cart = $_SESSION['alloc'];
-
+       
+       if ($cart->type == ST_JOURNAL && $cart->bank_amount < 0)
+       {
+               $cart->bank_amount = -$cart->bank_amount;
+               $cart->amount = -$cart->amount;
+       }       
     display_heading(sprintf(_("Allocation of %s # %d"), $systypes_array[$cart->type], $cart->trans_no));
 
     display_heading($cart->person_name);
 
     display_heading2(_("Date:") . " <b>" . $cart->date_ . "</b>");
-       display_heading2(_("Total:"). " <b>" . price_format($cart->bank_amount).' '.$cart->currency."</b>");
 
        if (floatcmp($cart->bank_amount, $cart->amount))
-       {
-           $total = _("Amount ot be settled:") . " <b>" . price_format($cart->amount).' '.$cart->person_curr."</b>";
-               if ($cart->currency != $cart->person_curr)
-               $total .= sprintf(" (%s %s/%s)",  exrate_format($cart->bank_amount/$cart->amount), $cart->currency, $cart->person_curr);
-               display_heading2($total);
-       }
+               display_heading2(_("Total:"). " <b>" . price_format($cart->bank_amount).' '.$cart->currency."</b>");
+
+       $total = _("Amount to be settled:") . " <b>" . '<span id="total">'.price_format($cart->amount).'</span> '.$cart->person_curr."</b>";
+       if ($cart->currency != $cart->person_curr)
+               $total .= sprintf(" (%s %s/%s)",  exrate_format($cart->bank_amount/$cart->amount), $cart->currency, $cart->person_curr);
+       display_heading2($total);
 
     echo "<br>";
 
@@ -90,7 +93,7 @@ if (isset($_POST['Process']))
 {
        if (check_allocations())
        {
-               $_SESSION['alloc']->write();
+               write_cust_allocation($_SESSION['alloc']);
                clear_allocations();
                $_POST['Cancel'] = 1;
        }
@@ -126,4 +129,3 @@ if (isset($_SESSION['alloc']))
 
 end_page();
 
-?>
\ No newline at end of file