X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_input.inc;h=bdb7e94545bba833171ea38d60b22a969facea16;hb=5ac9ea61baac0cf298b07317051da51e781645b7;hp=a6537a83c8bd2a06ae407c980154ecaf1a6f3a6a;hpb=53d942f2a0d20cce5e9c409c6485867ce0869e4d;p=fa-stable.git diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index a6537a83..bdb7e945 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -37,6 +37,14 @@ function find_submit($prefix, $numeric=true) } return $numeric ? -1 : null; } +/* + Helper function. + Returns true if input $name with $submit_on_change option set is subject to update. +*/ +function input_changed($name) +{ + return isset($_POST['_'.$name.'_changed']); +} //------------------------------------------------------------------------------ // @@ -85,10 +93,16 @@ function input_num($postname=null, $dflt=0) } //--------------------------------------------------------------------------------- +// +// Thanks to hidden fields buffering hidden() helper can be used in arbitrary places and +// proper html structure is still preserved. Buffered hidden fields are output on the nearest +// table or form closing tag (see output_hidden()). +// +$hidden_fields = array(); function hidden($name, $value=null, $echo=true) { - global $Ajax; + global $Ajax, $hidden_fields; if ($value === null) $value = get_post($name); @@ -96,7 +110,7 @@ function hidden($name, $value=null, $echo=true) $ret = ""; $Ajax->addUpdate($name, $name, $value); if ($echo) - echo $ret."\n"; + $hidden_fields[] = $ret; else return $ret; } @@ -128,7 +142,7 @@ function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=fal } elseif (!is_bool($atype)) { // necessary: switch uses '==' - $aspect = "aspect='$atype' "; + $aspect = " aspect='$atype' "; $types = explode(' ', $atype); foreach ($types as $type) { @@ -156,7 +170,7 @@ function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=fal ." name=\"$name\" id=\"$name\" value=\"$value\"" .($title ? " title='$title'" : '') .">" - .($icon ? "" : '') + .($icon ? "" : '') ."$value" ."\n"; if ($echo) @@ -188,6 +202,7 @@ function submit_center_last($name, $value, $title=false, $async=false, $icon=fal /* For following controls: 'both' - use both Ctrl-Enter and Escape hotkeys + 'upgrade' - use Ctrl-Enter with progress ajax indicator and Escape hotkeys. Nonajax request for OK option is performed. 'cancel' - apply to 'RESET' button */ function submit_add_or_update($add=true, $title=false, $async=false, $clone=false) @@ -196,7 +211,10 @@ function submit_add_or_update($add=true, $title=false, $async=false, $clone=fals if ($async === 'both') { $async = 'default'; $cancel = 'cancel'; - } + } + elseif ($async === 'upgrade') { + $async = 'default nonajax process'; $cancel = 'cancel'; + } else if ($async === 'default') $cancel = true; else if ($async === 'cancel') @@ -269,7 +287,7 @@ function set_icon($icon, $title=false) global $path_to_root; if (basename($icon) === $icon) // standard icons does not contain path separator $icon = "$path_to_root/themes/".user_theme()."/images/$icon"; - return "\n"; + return "\n"; } function button($name, $value, $title=false, $icon=false, $aspect='') @@ -291,7 +309,7 @@ function button($name, $value, $title=false, $icon=false, $aspect='') ."' value='1'" . ($title ? " title='$title'":" title='$value'") . ($aspect ? " aspect='$aspect'" : '') . $rel - ." />".set_icon($icon)."\n"; + ." >".set_icon($icon)."\n"; } else return "\n"; + ." >\n"; } function button_cell($name, $value, $title=false, $icon=false, $aspect='') @@ -387,7 +405,7 @@ function check_row($label, $name, $value=null, $submit_on_change=false, $title=f function radio($label, $name, $value, $selected=null, $submit_on_change=false) { if (!isset($selected)) - $selected = get_post($name) == $value; + $selected = get_post($name) === (string)$value; if ($submit_on_change === true) $submit_on_change = @@ -465,14 +483,14 @@ function qty_cell($label, $bold=false, $dec=null, $id=null) label_cell(number_format2($label, $dec), "nowrap align=right", $id); } -function label_cells($label, $value, $params="", $params2="", $id='') +function label_cells($label, $value, $params="", $params2="", $id=null) { if ($label != null) echo "$label\n"; label_cell($value, $params2, $id); } -function label_row($label, $value, $params="", $params2="", $leftfill=0, $id='') +function label_row($label, $value, $params="", $params2="", $leftfill=0, $id=null) { echo ""; if ($params == "") @@ -486,6 +504,16 @@ function label_row($label, $value, $params="", $params2="", $leftfill=0, $id='') echo "\n"; } +function text_input($name, $value=null, $size='', $max='', $title='', $params='') +{ + if ($value === null) + $value = get_post($name); + + return ""; +} + //----------------------------------------------------------------------------------- function text_cells($label, $name, $value=null, $size="", $max="", $title=false, @@ -498,11 +526,7 @@ function text_cells($label, $name, $value=null, $size="", $max="", $title=false, label_cell($label, $labparams); echo ""; - if ($value === null) - $value = get_post($name); - echo ""; + echo text_input($name, $value, $size, $max, $title, $inparams); if ($post_label != "") echo " " . $post_label; @@ -606,7 +630,7 @@ function link_row_ex($label, $name, $size, $max=null, $title=null, $value=null, function date_cells($label, $name, $title = null, $check=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null, $submit_on_change=false) { - global $use_date_picker, $path_to_root, $Ajax; + global $path_to_root, $Ajax; if (!isset($_POST[$name]) || $_POST[$name] == "") { @@ -624,7 +648,7 @@ function date_cells($label, $name, $title = null, $check=null, $inc_days=0, $_POST[$name] = $dd; } } - if ($use_date_picker) + if (user_use_date_picker()) { $calc_image = (file_exists("$path_to_root/themes/".user_theme()."/images/cal.gif")) ? "$path_to_root/themes/".user_theme()."/images/cal.gif" : "$path_to_root/themes/default/images/cal.gif"; @@ -667,7 +691,7 @@ function date_row($label, $name, $title=null, $check=null, $inc_days=0, $inc_mon function password_row($label, $name, $value) { echo "$label"; - label_cell(""); + label_cell(""); echo "\n"; } @@ -676,7 +700,7 @@ function file_cells($label, $name, $id="") { if ($id != "") $id = "id='$id'"; - label_cells($label, ""); + label_cells($label, ""); } function file_row($label, $name, $id = "") { @@ -943,26 +967,6 @@ function supplier_credit_row($supplier, $credit, $parms='') ."", $parms); } -/* - Edit transaction link to be used in transaction inquires -*/ -function edit_trans_link($trans_type, $trans_no, $url='') -{ - global $path_to_root, $trans_editors; - - if (!$url) $url = @$trans_editors[$trans_type]; - - if (!$trans_no || !$url) - return ''; - - if (is_closed_trans($trans_type, $trans_no)) { - return set_icon(ICON_CLOSED, _('Closed')); - } else { - $link_text = user_graphic_links() ? set_icon(ICON_EDIT, _('Edit')) : _('Edit'); - return "$link_text"; - } -} - function bank_balance_row($bank_acc, $parms='') { global $path_to_root; @@ -977,4 +981,3 @@ function bank_balance_row($bank_acc, $parms='') ."", $parms); } -?> \ No newline at end of file