Changed the Quantity routines to use the Item Units decimals if any. A lot of files.
[fa-stable.git] / sales / includes / ui / sales_credit_ui.inc
index 45ef3b4d1adefb9d20c5f0fd3ea239259715e9c0..3267bb4343c029d6d1e2a76d9b89a5ad53dbf643 100644 (file)
@@ -48,7 +48,7 @@ function display_credit_header(&$order)
            ref_row(_("Reference").':', 'ref');
        else
            label_row(_("Reference").':', $_POST['ref'] );
-       
+
 
 
        echo "</table>";
@@ -128,7 +128,7 @@ function display_credit_items($title, &$order)
 
            label_cell("<a target='_blank' href='$path_to_root/inventory/inquiry/stock_status.php?" . SID . "stock_id=" . $line->stock_id . "'>$line->stock_id</a>");
            label_cell($line->item_description, "nowrap");
-           qty_cell($line->qty_dispatched);
+           qty_cell($line->qty_dispatched, false, get_qty_dec($line->stock_id));
            label_cell($line->units);
            amount_cell($line->price);
 
@@ -182,7 +182,7 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
        {
 
                $_POST['stock_id'] = $order->line_items[$id]->stock_id;
-               $_POST['qty'] = qty_format($order->line_items[$id]->qty_dispatched);
+               $_POST['qty'] = qty_format($order->line_items[$id]->qty_dispatched, $_POST['stock_id'], $dec);
                $_POST['price'] = price_format($order->line_items[$id]->price);
                $_POST['Disc'] = percent_format(($order->line_items[$id]->discount_percent)*100);
                $_POST['units'] = $order->line_items[$id]->units;
@@ -192,31 +192,21 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
        }
        else
        {
-               global $no_item_list; 
-               if ($no_item_list)
-               {
-                       echo "<td colspan=2>\n";
-                       stock_items_list('stock_id', null, false, true);
-                       echo "</td>\n";
-               }
-               else
-               {
-                 text_cells(null, "StockID2", "", 12, 10, "", "", "onkeyup='recalcAccounts();' onKeyDown='if (event.keyCode==13) event.keyCode=9;' onblur='return setAccount(0, true);'");
-                       stock_items_list_cells(null, 'stock_id', null, false, false, "onchange='return setAccount(1, true)'");
-               }
-               $item_info = get_item_edit_info($_POST['stock_id']);
+               stock_items_list_cells(null,'stock_id', null, false, true);
+               $item_info = get_item_edit_info($_POST['stock_id']);
 
                $_POST['units'] = $item_info["units"];
 
-               $_POST['qty'] = qty_format(0);
-               $_POST['price'] = get_price($_POST['stock_id'],
-                    $order->customer_currency, $order->sales_type);
+               $_POST['qty'] = qty_format(0, $_POST['stock_id'], $dec);
+               $_POST['price'] = price_format(get_price($_POST['stock_id'], $order->customer_currency,
+                   $order->sales_type, $order->price_factor, $order->document_date));
+
                // default to the customer's discount %
                $_POST['Disc'] = percent_format($order->default_discount * 100);
        }
 
 
-       qty_cells(null, 'qty', $_POST['qty']);
+       qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
 //     if ($order->trans_no!=0) {
 //             amount_cell($line_no==-1 ? 0 :$order->line_items[$line_no]->qty_done);
 //     }
@@ -231,6 +221,7 @@ function credit_edit_item_controls(&$order, $rowcounter, $line_no=-1)
                edit_button_cell('UpdateItem', _("Update"));
                edit_button_cell('CancelItemChanges', _("Cancel"));
                hidden('line_no', $line_no);
+               set_focus('qty');
        }
        else
        {