X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_input.inc;h=a2355cfb02ee4f34c8823d65c63a1feb6910f539;hb=4098636a10a25952a38e1b0c8f6e80dff44ae4e7;hp=588f867c31ddd381387a3c6a90478d6457a6cc24;hpb=4e31fd74b18825d8ac35f4a38b96ef33a08c2025;p=fa-stable.git diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index 588f867c..a2355cfb 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -1,19 +1,14 @@ . + See the License here . ***********************************************************************/ - -function get_post($name, $dflt='') -{ - return ((!isset($_POST[$name]) || $_POST[$name] === '') ? $dflt : $_POST[$name]); -} // // Sets local POST value and adds Value to ajax posting if needed // @@ -103,21 +98,48 @@ function hidden($name, $value=null, $echo=true) else return $ret; } - -function submit($name, $value, $echo=true, $title=false, $async=false, $icon=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"; if ($echo) echo $submit_str; @@ -145,14 +167,28 @@ function submit_center_last($name, $value, $title=false, $async=false, $icon=fal submit($name, $value, true, $title, $async, $icon); echo ""; } - +/* + For following controls: + 'both' - use both Ctrl-Enter and Escape hotkeys + 'cancel' - apply to 'RESET' button +*/ function submit_add_or_update($add=true, $title=false, $async=false) { + $cancel = $async; + + if ($async === 'both') { + $async = 'default'; $cancel = 'cancel'; + } + else if ($async === 'default') + $cancel = true; + else if ($async === 'cancel') + $async = true; + if ($add) submit('ADD_ITEM', _("Add new"), true, $title, $async); else { submit('UPDATE_ITEM', _("Update"), true, $title, $async); - submit('RESET', _("Cancel"), true, $title, $async); + submit('RESET', _("Cancel"), true, $title, $cancel); } } @@ -163,14 +199,6 @@ function submit_add_or_update_center($add=true, $title=false, $async=false) echo ""; } -/* -function submit_add_or_update_row($add=true) -{ - echo ""; - submit_add_or_update($add); - echo "\n"; -} -*/ function submit_add_or_update_row($add=true, $right=true, $extra="", $title=false, $async=false) { echo ""; @@ -203,6 +231,11 @@ function submit_return($name, $value, $title=false, $async=false) submit($name, $value, true, $title, $async); } } + +function submit_js_confirm($name, $msg) { + add_js_source( + "_validate.$name=function(){ return confirm('$msg');};"); +}; //----------------------------------------------------------------------------------- function set_icon($icon, $title=false) @@ -221,7 +254,7 @@ function button($name, $value, $title=false, $icon=false) $icon = ICON_DELETE; return "