Data picker omitted in kbd tabbing sequence
[fa-stable.git] / includes / ui / ui_input.inc
index aab5fd18c5d3873ea564282878d5de6060f26b41..67abbbde5861271a68e393e98e56c33cf2e998db 100644 (file)
@@ -1,5 +1,25 @@
 <?php
 
+//------------------------------------------------------------------------------
+//    Seek for _POST variable with $prefix.
+//    If var is found returns variable name with prefix stripped,
+//    and null or -1 otherwise.
+//
+function find_submit($prefix, $numeric=true) {
+
+    foreach($_POST as $postkey=>$postval ) {
+       if (strpos($postkey, $prefix) === 0) {
+               $id = substr($postkey, strlen($prefix));
+               return $numeric ? (int)$id : $id;
+       }
+    }
+    return $numeric ? -1 : null;
+}
+
+//------------------------------------------------------------------------------
+//
+//     Read numeric value from user formatted input
+//
 function input_num($postname=null) {
        if (!isset($_POST[$postname])) 
          return null;
@@ -18,6 +38,7 @@ function hidden($name, $value)
 
 function submit($name, $value, $echo=true)
 {
+
        $submit_str = "<input type=\"submit\" class=\"inputsubmit\" name=\"$name\" value=\"$value\">\n";
        if ($echo)
                echo $submit_str;
@@ -98,7 +119,7 @@ function submit_row($name, $value, $right=true, $extra="")
 
 function button($name, $value, $onclick)
 {
-       echo "<input type=\"button\" class=\"inputsubmit\" name=\"$name\" value=\"$value\" onclick=\"$onclick\" />\n";
+  echo "<input type=\"button\" class=\"inputsubmit\" name=\"$name\" value=\"$value\" onclick=\"$onclick\" />\n";
 }
 
 function button_cell($name, $value, $onclick)
@@ -164,25 +185,25 @@ function label_cell($label, $params="")
 function amount_cell($label, $bold=false)
 {
        if ($bold)
-               label_cell("<b>".number_format2($label,user_price_dec())."</b>", "nowrap align=right");
+               label_cell("<b>".price_format($label)."</b>", "nowrap align=right");
        else
-               label_cell(number_format2($label,user_price_dec()), "nowrap align=right");
+               label_cell(price_format($label), "nowrap align=right");
 }
 
 function percent_cell($label, $bold=false)
 {
        if ($bold)
-               label_cell("<b>".number_format2($label,user_percent_dec())."</b>", "nowrap align=right");
+               label_cell("<b>".percent_format($label)."</b>", "nowrap align=right");
        else
-               label_cell(number_format2($label,user_percent_dec()), "nowrap align=right");
+               label_cell(percent_format($label), "nowrap align=right");
 }
 
-function qty_cell($label, $bold=false)
+function qty_cell($label, $bold=false, $dec=null)
 {
        if ($bold)
-               label_cell("<b>".number_format2($label,user_qty_dec())."</b>", "nowrap align=right");
+               label_cell("<b>".qty_format($label, $dec)."</b>", "nowrap align=right");
        else
-               label_cell(number_format2($label,user_qty_dec()), "nowrap align=right");
+               label_cell(qty_format($label, $dec), "nowrap align=right");
 }
 
 function label_cells($label, $value, $params="", $params2="")
@@ -291,7 +312,7 @@ function date_cells($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_
                        $_POST[$name] = $init;
        }
        if ($use_date_picker)
-               $post_label = "<a href=\"javascript:date_picker(document.forms[0].$name);\">"
+               $post_label = "<a tabindex='-1' href=\"javascript:date_picker(document.forms[0].$name);\">"
                . "     <img src='$path_to_root/themes/default/images/cal.gif' width='16' height='16' border='0' alt='"._('Click Here to Pick up the date')."'></a>\n";
        else
                $post_label = "";
@@ -331,11 +352,13 @@ function percent_row($label, $name, $init=null)
                        $_POST[$name] = $init== null ? '' : $init;
        }
 
-       small_amount_row($label, $name, $_POST[$name], null, "%");
+       small_amount_row($label, $name, $_POST[$name], null, "%", user_percent_dec());
 }
 
-function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null)
+function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null, $dec=null)
 {
+       if (!isset($dec))
+         $dec = user_price_dec();
        if (!isset($_POST[$name]) || $_POST[$name] == "")
        {
                if ($init)
@@ -351,7 +374,7 @@ function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=nu
 
        echo "<td>";
 
-       echo "<input class='amount' type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" value=\"" . $_POST[$name]. "\">";
+       echo "<input class='amount' type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" dec=\"$dec\" value=\"" . $_POST[$name]. "\">";
 
        if ($post_label)
                echo " " . $post_label;
@@ -362,30 +385,69 @@ function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=nu
 
 //-----------------------------------------------------------------------------------
 
-function amount_cells($label, $name, $init=null, $params=null, $post_label=null)
+function amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
 {
-       amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label);
+       amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec);
 }
 
-function amount_row($label, $name, $init=null, $params=null, $post_label=null)
+function amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
 {
        echo "<tr>";
-       amount_cells($label, $name, $init, $params, $post_label);
+       amount_cells($label, $name, $init, $params, $post_label, $dec);
        echo "</tr>\n";
 }
 
-function small_amount_row($label, $name, $init=null, $params=null, $post_label=null)
+function small_amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
 {
        echo "<tr>";
-       small_amount_cells($label, $name, $init, $params, $post_label);
+       small_amount_cells($label, $name, $init, $params, $post_label, $dec);
        echo "</tr>\n";
 }
 
 //-----------------------------------------------------------------------------------
 
-function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null)
+function qty_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+       if(!isset($dec))
+         $dec = user_qty_dec();
+
+       amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec);
+}
+
+function qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+       if(!isset($dec))
+         $dec = user_qty_dec();
+
+       echo "<tr>";
+       amount_cells($label, $name, $init, $params, $post_label, $dec);
+       echo "</tr>\n";
+}
+
+function small_qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+       if(!isset($dec))
+         $dec = user_qty_dec();
+
+       echo "<tr>";
+       small_amount_cells($label, $name, $init, $params, $post_label, $dec);
+       echo "</tr>\n";
+}
+
+//-----------------------------------------------------------------------------------
+
+function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+       amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label, $dec);
+}
+
+//-----------------------------------------------------------------------------------
+
+function small_qty_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
 {
-       amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label);
+  if (!isset($dec))
+         $dec = user_qty_dec();
+       amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label, $dec);
 }
 
 //-----------------------------------------------------------------------------------