Add color on available quantity
authorMaxime Bourget <bmx007@gmail.com>
Mon, 3 Jun 2013 20:12:46 +0000 (21:12 +0100)
committerMaxime Bourget <bmx007@gmail.com>
Mon, 3 Jun 2013 20:12:46 +0000 (21:12 +0100)
includes/order_lines.inc
order_lines_view.php

index 5f8d922cbe8458fc0ed226acb81861ab995751d9..92391f6034458ef3efb3c9447e1562e7dca6a111 100644 (file)
@@ -110,6 +110,15 @@ function aggregate_comment($row) {
        return '';
 }
 
+function available_quantity($row, $available) {
+       $quantity = $row['quantity'];
+       $class = '';
+       if($available== 0) $class = 'limited';
+       else if($quantity > $available)  $class = 'partial';
+
+       return "<span class='$class'>$available<span>";
+}
+
 function input_date_details($row, $date) {
 $row_id = $row['id'];
        $name = compute_input_name($row, 'required_date');
@@ -137,7 +146,7 @@ function get_order_details_extra($customer_id, $location) {
        $sql = "SELECT sod.id
        , so.order_no
        , stk_code
-       , sod.quantity - qty_sent
+       , sod.quantity - qty_sent quantity
        , GREATEST(0, LEAST(qoh.quantity  - quantity_before, sod.quantity - qty_sent))
        , quantity_before
        , required_date
index e1366261e62fa2702f57fd929e3563a3ca40c94d..2f0a14ad7d5ee66b075702e98b4a75c6f590408f 100644 (file)
@@ -74,7 +74,7 @@ if($customer_id) {
                ,       _("Order #") => array('fun'=>'view_link', 'ord' => '')
                ,_("Item Code") => array('ord' => '', 'fun' => 'item_link')
                ,_("Quantity") => array('type' => 'qty', 'dec' => 0)
-               ,_("Available") => array('type' => 'qty', 'dec' => 0, 'ord' => '')
+               ,_("Available") => array('fun' => 'available_quantity', 'dec' => 0, 'ord' => '')
        ,_("Required Date") => array('fun' => 'input_date_details', 'ord' => '')
        ,_("Comment") => array('fun' => 'input_comment_details', 'ord' => '')
        );