X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_input.inc;h=b775ede018e5b8ae68d83ae3f734f3e812043bc3;hb=b2d2db8dd932f3b97e116784463da996f603787d;hp=6cf467a4e6f0d30651a986a6e490e2a602f18f25;hpb=fde90a2cb554d70d68924fbb0bf7b617850f721d;p=fa-stable.git diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index 6cf467a4..b775ede0 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -32,15 +32,45 @@ 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 = 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; + return $dflt; return user_numeric($_POST[$postname]); } @@ -110,9 +140,11 @@ function submit_center_last($name, $value, $title=false, $async=false) function submit_add_or_update($add=true, $title=false, $async=false) { if ($add) - submit('ADD_ITEM', _("Save"), true, $title, $async); - else + submit('ADD_ITEM', _("Add new"), true, $title, $async); + else { submit('UPDATE_ITEM', _("Update"), true, $title, $async); + submit('RESET', _("Cancel"), true, $title, $async); + } } function submit_add_or_update_center($add=true, $title=false, $async=false) @@ -152,7 +184,7 @@ function submit_row($name, $value, $right=true, $extra="", $title=false, $async= echo ""; if ($right) echo " \n"; - submit_cells($name, $value, $extra, $title); + submit_cells($name, $value, $extra, $title, $async); echo "\n"; } //---------------------------------------------------------------------------------