X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_input.inc;h=a2355cfb02ee4f34c8823d65c63a1feb6910f539;hb=310a0d3ae5aeacbdaa0069546cc2652ac7518e6b;hp=ad27a4491b16716dd193c4fa7ccca85a3e731260;hpb=a4a9f9a8eedfd2ca31fb5e213256c3f572cbad4c;p=fa-stable.git
diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc
index ad27a449..a2355cfb 100644
--- a/includes/ui/ui_input.inc
+++ b/includes/ui/ui_input.inc
@@ -1,9 +1,14 @@
.
+***********************************************************************/
//
// Sets local POST value and adds Value to ajax posting if needed
//
@@ -32,15 +37,47 @@ function find_submit($prefix, $numeric=true)
}
return $numeric ? -1 : null;
}
+//------------------------------------------------------------------------------
+//
+// Helper function for simple db table editor pages
+//
+function simple_page_mode($numeric_id = true)
+{
+ global $Ajax, $Mode, $selected_id;
+
+ $default = $numeric_id ? -1 : '';
+ $selected_id = get_post('selected_id', $default);
+ foreach (array('ADD_ITEM', 'UPDATE_ITEM', 'RESET') as $m) {
+ if (isset($_POST[$m])) {
+ $Ajax->activate('_page_body');
+ if ($m == 'RESET')
+ $selected_id = $default;
+ $Mode = $m; return;
+ }
+ }
+ foreach (array('Edit', 'Delete') as $m) {
+ foreach ($_POST as $p => $pvar) {
+ if (strpos($p, $m) === 0) {
+// $selected_id = strtr(substr($p, strlen($m)), array('%2E'=>'.'));
+ unset($_POST['_focus']); // focus on first form entry
+ $selected_id = quoted_printable_decode(substr($p, strlen($m)));
+ $Ajax->activate('_page_body');
+ $Mode = $m;
+ return;
+ }
+ }
+ }
+ $Mode = '';
+}
//------------------------------------------------------------------------------
//
// Read numeric value from user formatted input
//
-function input_num($postname=null)
+function input_num($postname=null, $dflt=null)
{
- if (!isset($_POST[$postname]))
- return null;
+ if (!isset($_POST[$postname]) || $_POST[$postname] == "")
+ return $dflt;
return user_numeric($_POST[$postname]);
}
@@ -61,58 +98,98 @@ function hidden($name, $value=null, $echo=true)
else
return $ret;
}
-
-//---------------------------------------------------------------------------------
-// Submit button.
-// $async parameter can have 3 values:
-// false - normal submit via form action
-// true - when js is on submition via ajax call
-// null - fallback button not visible in js enabled mode
-//
-function submit($name, $value, $echo=true, $title=false, $async=false)
-{
+/*
+ Universal submit form button.
+ $atype - type of submit:
+ Normal submit:
+ false - normal button; optional icon
+ null - button visible only in fallback mode; optional icon
+ Ajax submit:
+ true - standard button; optional icon
+ 'process' - displays progress bar during call; optional icon
+ 'default' - default form submit on Ctrl-Enter press; dflt ICON_OK icon
+ 'cancel' - cancel form entry on Escape press; dflt ICON_CANCEL
+*/
+function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=false)
+{
+ global $path_to_root;
+
+ $aspect='';
+ if (!is_bool($atype)) // necessary: switch uses '=='
+ switch($atype) {
+ case 'process':
+ $aspect = " aspect='process'"; break;
+ case 'default':
+ $aspect = " aspect='default'";
+ if ($icon===false) $icon=ICON_SUBMIT; break;
+ case 'cancel':
+ $aspect = " aspect='cancel'";
+ if ($icon===false) $icon=ICON_ESCAPE; break;
+ case null:
+ $aspect = fallback_mode() ?
+ " aspect='fallback'" : " style='display:none;'"; break;
+ }
default_focus($name);
- $submit_str = "\n";
+ .">"
+ .($icon ? "" : '')
+ ."$value"
+ ."\n";
if ($echo)
echo $submit_str;
else
return $submit_str;
}
-function submit_center($name, $value, $echo=true, $title=false, $async=false)
+function submit_center($name, $value, $echo=true, $title=false, $async=false, $icon=false)
{
echo "