Stock item types moved to types.inc
[fa-stable.git] / includes / ui / ui_input.inc
index f90da9100dcebd632e85baaf5044c4415fb7f41f..434117e652553e16ffeabdbc06b5cebe0af80837 100644 (file)
@@ -1,19 +1,14 @@
 <?php
 /**********************************************************************
     Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU Affero General Public License,
-       AGPL, as published by the Free Software Foundation, either version 
-       of the License, or (at your option) any later version.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-
-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 = "<button class=\""
-           .($async ? 'ajaxsubmit' : 'inputsubmit')
+           .($atype ? 'ajaxsubmit' : 'inputsubmit')
                ."\" type=\"submit\""
-               .($async === null ? (fallback_mode() ? ' aspect="fallback"' : " style='display:none;'" ): 
-                       ($async === 'process' ? 'aspect="process"' : '') )
+               .$aspect
            ." name=\"$name\"  id=\"$name\" value=\"$value\""
            .($title ? " title='$title'" : '')
-           ."><span>$value</span>"
+           .">"
                .($icon ? "<img src='$path_to_root/themes/".user_theme()."/images/$icon'>" : '')
+               ."<span>$value</span>"
                ."</button>\n";
        if ($echo)
                echo $submit_str;