From 2150d50b1dbe375fffa2f868ad2bdd791f4ec894 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 22 Mar 2009 16:59:54 +0000 Subject: [PATCH] Optional check for current date in date_cells()/date_row() --- includes/ui/ui_input.inc | 72 +++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index df269cd6..a85f41a8 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -409,18 +409,19 @@ function label_row($label, $value, $params="", $params2="", $leftfill=0, $id='') //----------------------------------------------------------------------------------- -function text_cells($label, $name, $value=null, $size="", $max="", $title=false, $params="", $post_label="", $disabled="") +function text_cells($label, $name, $value=null, $size="", $max="", $title=false, + $labparams="", $post_label="", $inparams="") { global $Ajax; default_focus($name); if ($label != null) - label_cell($label, $params); + label_cell($label, $labparams); echo ""; if ($value === null) $value = get_post($name); - echo ""; @@ -431,7 +432,8 @@ function text_cells($label, $name, $value=null, $size="", $max="", $title=false, $Ajax->addUpdate($name, $name, $value); } -function text_cells_ex($label, $name, $size, $max=null, $init=null, $title=null, $params=null, $post_label=null, $submit_on_change=false) +function text_cells_ex($label, $name, $size, $max=null, $init=null, $title=null, + $labparams=null, $post_label=null, $submit_on_change=false) { global $Ajax; @@ -444,7 +446,7 @@ function text_cells_ex($label, $name, $size, $max=null, $init=null, $title=null, $_POST[$name] = ""; } if ($label != null) - label_cell($label, $params); + label_cell($label, $labparams); if (!isset($max)) $max = $size; @@ -503,45 +505,61 @@ function link_row_ex($label, $name, $size, $max=null, $title=null, $value=null, } //----------------------------------------------------------------------------------- - -function date_cells($label, $name, $title = null, $init=null, $inc_days=0, +// +// Since FA 2.2 $init parameter is superseded by $check. +// When $check!=null current date is displayed in red when set to other +// than current date. +// +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; + global $use_date_picker, $path_to_root, $Ajax; + if (!isset($_POST[$name]) || $_POST[$name] == "") { - if (!$init) + if ($inc_years == 1001) + $_POST[$name] = null; + else { - if ($inc_years == 1001) - $_POST[$name] = null; - else - { - $dd = Today(); - if ($inc_days != 0) - $dd = add_days($dd, $inc_days); - if ($inc_months != 0) - $dd = add_months($dd, $inc_months); - if ($inc_years != 0) - $dd = add_years($dd, $inc_years); - $_POST[$name] = $dd; - } + $dd = Today(); + if ($inc_days != 0) + $dd = add_days($dd, $inc_days); + if ($inc_months != 0) + $dd = add_months($dd, $inc_months); + if ($inc_years != 0) + $dd = add_years($dd, $inc_years); + $_POST[$name] = $dd; } - else - $_POST[$name] = $init; } if ($use_date_picker) $post_label = "" . " "._(\n"; else $post_label = ""; - text_cells_ex($label, $name, 9, 12, $_POST[$name], $title, $params, $post_label, $submit_on_change); + + if ($label != null) + label_cell($label, $params); + + echo ""; + + $class = $submit_on_change ? 'class="searchbox"' : ''; + + $aspect = $check ? 'aspect="cdate"' : ''; + if ($check && (get_post($name) != Today())) + $aspect .= ' style="color:#FF0000"'; + + echo " $post_label"; + echo "\n"; + $Ajax->addUpdate($name, $name, $_POST[$name]); } -function date_row($label, $name, $title=null, $init=null, $inc_days=0, $inc_months=0, +function date_row($label, $name, $title=null, $check=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, + date_cells($label, $name, $title, $check, $inc_days, $inc_months, $inc_years, $params, $submit_on_change); echo "\n"; } -- 2.30.2