X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fui%2Fui_input.inc;h=6c09d0979f83f6fcf806ed45628396a49152249a;hb=7d866f768b8be95c82ab0664721da9ca09c7604f;hp=ab33f649a81ce3cb4418b2ad9f4f4a5e191e03d7;hpb=0c1bcd8ce3c089d7ddb3722a097f8fc8417f41e6;p=fa-stable.git diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index ab33f649..6c09d097 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -1,5 +1,32 @@ $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; + + return user_numeric($_POST[$postname]); +} + //--------------------------------------------------------------------------------- function hidden($name, $value) @@ -11,6 +38,7 @@ function hidden($name, $value) function submit($name, $value, $echo=true) { + default_focus($name); $submit_str = "\n"; if ($echo) echo $submit_str; @@ -91,7 +119,8 @@ function submit_row($name, $value, $right=true, $extra="") function button($name, $value, $onclick) { - echo "\n"; + default_focus($name); + echo "\n"; } function button_cell($name, $value, $onclick) @@ -112,6 +141,7 @@ function check_value($name) function check($label, $name, $value, $submit_on_change=false) { + default_focus($name); if ($label) echo $label . " "; @@ -157,25 +187,25 @@ function label_cell($label, $params="") function amount_cell($label, $bold=false) { if ($bold) - label_cell("".number_format2($label,user_price_dec())."", "nowrap align=right"); + label_cell("".price_format($label)."", "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("".number_format2($label,user_percent_dec())." %", "nowrap align=right"); + label_cell("".percent_format($label)."", "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("".number_format2($label,user_qty_dec())."", "nowrap align=right"); + label_cell("".qty_format($label, $dec)."", "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="") @@ -198,6 +228,7 @@ function label_row($label, $value, $params="", $params2="", $leftfill=0) function text_cells($label, $name, $value, $size="", $max="", $params="", $post_label="", $disabled="") { + default_focus($name); if ($label != null) label_cell($label, $params); echo ""; @@ -214,6 +245,7 @@ function text_cells($label, $name, $value, $size="", $max="", $params="", $post_ function text_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null) { + default_focus($name); if (!isset($_POST[$name]) || $_POST[$name] == "") { if ($init) @@ -284,7 +316,7 @@ function date_cells($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_ $_POST[$name] = $init; } if ($use_date_picker) - $post_label = "" + $post_label = "" . " "._(\n"; else $post_label = ""; @@ -324,34 +356,109 @@ function percent_row($label, $name, $init=null) $_POST[$name] = $init== null ? '' : $init; } - text_row($label, $name, $_POST[$name], 6, 6, "", "%"); + 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, $dec=null) +{ + if (!isset($dec)) + $dec = user_price_dec(); + if (!isset($_POST[$name]) || $_POST[$name] == "") + { + if ($init) + $_POST[$name] = $init; + else + $_POST[$name] = ''; + } + if ($label != null) + label_cell($label, $params); + + if (!isset($max)) + $max = $size; + + echo ""; + + echo ""; + + if ($post_label) + echo " " . $post_label; + + echo "\n"; +} + + //----------------------------------------------------------------------------------- -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) { - text_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 ""; - amount_cells($label, $name, $init, $params, $post_label); + amount_cells($label, $name, $init, $params, $post_label, $dec); echo "\n"; } +function small_amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null) +{ + echo ""; + small_amount_cells($label, $name, $init, $params, $post_label, $dec); + echo "\n"; +} + +//----------------------------------------------------------------------------------- + +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 ""; + amount_cells($label, $name, $init, $params, $post_label, $dec); + echo "\n"; +} + +function small_qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null) +{ + if(!isset($dec)) + $dec = user_qty_dec(); + + echo ""; + small_amount_cells($label, $name, $init, $params, $post_label, $dec); + echo "\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_amount_cells($label, $name, $init=null, $params=null, $post_label=null) +function small_qty_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null) { - text_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); } //----------------------------------------------------------------------------------- function textarea_cells($label, $name, $value, $cols, $rows, $params="") { + default_focus($name); if ($label != null) echo "$label\n"; if ($value == null) @@ -370,6 +477,7 @@ function textarea_row($label, $name, $value, $cols, $rows, $params="") function text_row_with_submit($label, $name, $value, $size, $max, $input_name, $input_value) { + default_focus($name); echo "$label\n"; echo "";