Additional option for submit_add_or_update helpers.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 18 Mar 2009 21:05:50 +0000 (21:05 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 18 Mar 2009 21:05:50 +0000 (21:05 +0000)
includes/ui/ui_input.inc

index 434117e652553e16ffeabdbc06b5cebe0af80837..df269cd65f0950f75ba02129d74e33f72b5e6a49 100644 (file)
@@ -167,14 +167,28 @@ function submit_center_last($name, $value, $title=false, $async=false, $icon=fal
        submit($name, $value, true, $title, $async, $icon);
        echo "</center>";
 }
-
+/*
+       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);
        }
 }