X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_input.inc;h=08a4035b518fa3d06a8ab7a0feff03bc20cd22a0;hb=348062667e6a96e9849bf25de0f2a426b4f0b9c6;hp=2dcd14e14aa23406ca57ecff765b5b6fe18d4c18;hpb=132a27118a73827820a87093ad7e0b8af30ac44d;p=fa-stable.git
diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc
index 2dcd14e1..08a4035b 100644
--- a/includes/ui/ui_input.inc
+++ b/includes/ui/ui_input.inc
@@ -32,24 +32,60 @@ 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;
+ return $dflt;
return user_numeric($_POST[$postname]);
}
//---------------------------------------------------------------------------------
-function hidden($name, $value, $echo=true)
+function hidden($name, $value=null, $echo=true)
{
global $Ajax;
+
+ if ($value === null)
+ $value = get_post($name);
+
$ret = "";
$Ajax->addUpdate($name, $name, $value);
if ($echo)
@@ -58,49 +94,56 @@ function hidden($name, $value, $echo=true)
return $ret;
}
-//---------------------------------------------------------------------------------
-
-function submit($name, $value, $echo=true, $title=false, $async=false)
+function submit($name, $value, $echo=true, $title=false, $async=false, $icon=false)
{
+ global $path_to_root;
+
default_focus($name);
- $submit_str = "\n";
+ .">$value"
+ .($icon ? "" : '')
+ ."\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 "
";
- submit($name, $value, $echo, $title, $async);
+ submit($name, $value, $echo, $title, $async, $icon);
echo "";
}
-function submit_center_first($name, $value, $title=false, $async=false)
+function submit_center_first($name, $value, $title=false, $async=false, $icon=false)
{
echo "";
- submit($name, $value, true, $title, $async);
+ submit($name, $value, true, $title, $async, $icon);
echo " ";
}
-function submit_center_last($name, $value, $title=false, $async=false)
+function submit_center_last($name, $value, $title=false, $async=false, $icon=false)
{
echo " ";
- submit($name, $value, true, $title, $async);
+ submit($name, $value, true, $title, $async, $icon);
echo "";
}
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)
@@ -140,9 +183,16 @@ 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";
}
+
+function submit_return($name, $value, $title=false, $async=false)
+{
+ if (count($_SESSION['Context'])) {
+ submit($name, $value, true, $title, $async);
+ }
+}
//---------------------------------------------------------------------------------
function button($name, $value, $onclick, $title=false)
@@ -169,7 +219,7 @@ function check_value($name)
return 1;
}
-function check($label, $name, $value, $submit_on_change=false, $title=false)
+function check($label, $name, $value=null, $submit_on_change=false, $title=false)
{
global $Ajax;
@@ -177,8 +227,8 @@ function check($label, $name, $value, $submit_on_change=false, $title=false)
if ($label)
echo $label . " ";
- if ($value == null)
- $value = (!isset($_POST[$name]) ? 0 : $_POST[$name]);
+ if ($value === null)
+ $value = get_post($name,0);
echo "$label\n";
- echo "$value | \n";
+ label_cell($value, $params2, $id);
}
-function label_row($label, $value, $params="", $params2="", $leftfill=0)
+function label_row($label, $value, $params="", $params2="", $leftfill=0, $id='')
{
echo "";
- label_cells($label, $value, $params, $params2);
+ label_cells($label, $value, $params, $params2, $id);
if ($leftfill!=0)
echo " | ";
echo "
\n";
@@ -270,7 +320,7 @@ function label_row($label, $value, $params="", $params2="", $leftfill=0)
//-----------------------------------------------------------------------------------
-function text_cells($label, $name, $value, $size="", $max="", $title=false, $params="", $post_label="", $disabled="")
+function text_cells($label, $name, $value=null, $size="", $max="", $title=false, $params="", $post_label="", $disabled="")
{
global $Ajax;
@@ -279,8 +329,8 @@ function text_cells($label, $name, $value, $size="", $max="", $title=false, $par
label_cell($label, $params);
echo "";
- if ($value == null)
- $value = (!isset($_POST[$name]) ? "" : $_POST[$name]);
+ if ($value === null)
+ $value = get_post($name);
echo "";
@@ -344,7 +394,8 @@ function text_row_ex($label, $name, $size, $max=null, $title=null, $value=null,
//-----------------------------------------------------------------------------------
-function date_cells($label, $name, $title = null, $init=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null)
+function date_cells($label, $name, $title = null, $init=null, $inc_days=0,
+ $inc_months=0, $inc_years=0, $params=null, $submit_on_change=false)
{
global $use_date_picker, $path_to_root;
if (!isset($_POST[$name]) || $_POST[$name] == "")
@@ -373,13 +424,15 @@ function date_cells($label, $name, $title = null, $init=null, $inc_days=0, $inc_
. " \n";
else
$post_label = "";
- text_cells_ex($label, $name, 9, 12, $_POST[$name], $title, $params, $post_label);
+ text_cells_ex($label, $name, 9, 12, $_POST[$name], $title, $params, $post_label, $submit_on_change);
}
-function date_row($label, $name, $title=null, $init=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null)
+function date_row($label, $name, $title=null, $init=null, $inc_days=0, $inc_months=0,
+ $inc_years=0, $params=null, $submit_on_change=false)
{
echo " | ";
- date_cells($label, $name, $title, $init, $inc_days, $inc_months, $inc_years, $params);
+ date_cells($label, $name, $title, $init, $inc_days, $inc_months,
+ $inc_years, $params, $submit_on_change);
echo "
\n";
}
@@ -406,7 +459,7 @@ function percent_row($label, $name, $init=null)
if (!isset($_POST[$name]) || $_POST[$name]=="")
{
- $_POST[$name] = $init== null ? '' : $init;
+ $_POST[$name] = $init == null ? '' : $init;
}
small_amount_row($label, $name, $_POST[$name], null, "%", user_percent_dec());