'=2E',' '=>'=20','='=>'=3D','['=>'=5B'))).
+ "' value='1'" . ($title ? " title='$title'":" title='$value'")." />".set_icon($icon)."\n";
+ }
+ else
+ return " '=2E',' '=>'=20','='=>'=3D','['=>'=5B')))
+ ."' value='$value'"
+ .($title ? " title='$title'":'')." />\n";
+}
+
+function button_cell($name, $value, $title=false, $icon=false)
+{
+ echo "";
+ echo button($name, $value, $title, $icon);
+ echo " ";
+}
+
+function delete_button_cell($name, $value, $title=false)
+{
+ button_cell($name, $value, $title, ICON_DELETE);
}
+function edit_button_cell($name, $value, $title=false)
+{
+ button_cell($name, $value, $title, ICON_EDIT);
+}
//-----------------------------------------------------------------------------------
function check_value($name)
@@ -219,39 +288,52 @@ function check_value($name)
return 1;
}
-function check($label, $name, $value=null, $submit_on_change=false, $title=false)
+function checkbox($label, $name, $value=null, $submit_on_change=false, $title=false)
{
global $Ajax;
+ $str = '';
default_focus($name);
if ($label)
- echo $label . " ";
-
+ $str .= $label . " ";
+ if ($submit_on_change !== false) {
+ if ($submit_on_change === true)
+ $submit_on_change =
+ "JsHttpRequest.request(\"_{$name}_update\", this.form);";
+ }
if ($value === null)
$value = get_post($name,0);
- echo " \n";
+ $str .= " \n";
+
$Ajax->addUpdate($name, $name, $value);
+ return $str;
}
-function check_cells($label, $name, $value, $submit_on_change=false, $title=false)
+function check($label, $name, $value=null, $submit_on_change=false, $title=false)
+{
+ echo checkbox($label, $name, $value, $submit_on_change, $title);
+}
+
+function check_cells($label, $name, $value, $submit_on_change=false, $title=false,
+ $params='')
{
if ($label != null)
echo "$label \n";
- echo "";
- check(null, $name, $value, $submit_on_change, $title);
+ echo " ";
+ echo check(null, $name, $value, $submit_on_change, $title);
echo " ";
}
function check_row($label, $name, $value, $submit_on_change=false, $title=false)
{
echo "";
- check_cells($label, $name, $value, $submit_on_change, $title);
+ echo check_cells($label, $name, $value, $submit_on_change, $title);
echo " \n";
}
@@ -276,6 +358,11 @@ function label_cell($label, $params="", $id=null)
return $label;
}
+function email_cell($label, $params="", $id=null)
+{
+ label_cell("$label ", $params, $id);
+}
+
function amount_cell($label, $bold=false, $params="", $id=null)
{
if ($bold)
@@ -294,7 +381,7 @@ function percent_cell($label, $bold=false, $id=null)
// 2008-06-15. Changed
function qty_cell($label, $bold=false, $dec=null, $id=null)
{
- if ($dec == null)
+ if (!isset($dec))
$dec = get_qty_dec();
if ($bold)
label_cell("".number_format2($label, $dec)." ", "nowrap align=right", $id);
@@ -320,18 +407,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 " ";
@@ -342,7 +430,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;
@@ -355,7 +444,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;
@@ -393,45 +482,98 @@ function text_row_ex($label, $name, $size, $max=null, $title=null, $value=null,
}
//-----------------------------------------------------------------------------------
+function email_row($label, $name, $value, $size, $max, $title=null, $params="", $post_label="")
+{
+ if (get_post($name))
+ $label = "$label ";
+ text_row($label, $name, $value, $size, $max, $title, $params, $post_label);
+}
+
+function email_row_ex($label, $name, $size, $max=null, $title=null, $value=null, $params=null, $post_label=null)
+{
+ if (get_post($name))
+ $label = "$label ";
+ text_row_ex($label, $name, $size, $max, $title, $value, $params, $post_label);
+}
+
+function link_row($label, $name, $value, $size, $max, $title=null, $params="", $post_label="")
+{
+ $val = get_post($name);
+ if ($val) {
+ if (strpos($val,'http://')===false)
+ $val = 'http://'.$val;
+ $label = "$label ";
+ }
+ text_row($label, $name, $value, $size, $max, $title, $params, $post_label);
+}
-function date_cells($label, $name, $title = null, $init=null, $inc_days=0,
+function link_row_ex($label, $name, $size, $max=null, $title=null, $value=null, $params=null, $post_label=null)
+{
+ $val = get_post($name);
+ if ($val) {
+ if (strpos($val,'http://')===false)
+ $val = 'http://'.$val;
+ $label = "$label ";
+ }
+ text_row_ex($label, $name, $size, $max, $title, $value, $params, $post_label);
+}
+
+//-----------------------------------------------------------------------------------
+//
+// 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";
}
@@ -484,13 +626,17 @@ function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=nu
if (!isset($max))
$max = $size;
- echo "";
+ if ($label != null)
+ echo " ";
+ else
+ echo " ";
echo " ";
- if ($post_label)
- echo " " . $post_label;
-
+ if ($post_label) {
+ echo " $post_label ";
+ $Ajax->addUpdate($name, '_'.$name.'_label', $post_label);
+ }
echo " \n";
$Ajax->addUpdate($name, $name, $_POST[$name]);
$Ajax->addAssign($name, $name, 'dec', $dec);
@@ -609,6 +755,48 @@ function text_row_with_submit($label, $name, $value, $size, $max, $input_name, $
}
*/
//-----------------------------------------------------------------------------------
+//
+// When show_inactive page option is set
+// displays value of inactive field as checkbox cell.
+// Also updates database record after status change.
+//
+function inactive_control_cell($id, $value, $table, $key)
+{
+ global $Ajax;
+ $name = "Inactive". $id;
+ $value = $value ? 1:0;
+ if (check_value('show_inactive')) {
+ if (isset($_POST['LInact'][$id]) && (get_post('_Inactive'.$id.'_update') ||
+ get_post('Update')) && (check_value('Inactive'.$id) != $value)) {
+ update_record_status($id, !$value, $table, $key);
+ }
+ echo ''. checkbox(null, $name, $value, true, '', "align='center'")
+ . hidden("LInact[$id]", $value, false) . ' ';
+ }
+}
+//
+// Displays controls for optional display of inactive records
+//
+function inactive_control_row($th) {
+ echo ""
+ .""
+ . checkbox(null, 'show_inactive', null, true). _("Show also Inactive")
+ ."
"
+ . submit('Update', _('Update'), false, '', null)
+ ."
";
+}
+//
+// Inserts additional column header when display of inactive records is on.
+//
+function inactive_control_column(&$th) {
+ global $Ajax;
+
+ if (check_value('show_inactive'))
+ array_insert($th, count($th)-2 , _("Inactive"));
+ if (get_post('_show_inactive_update')) {
+ $Ajax->activate('_page_body');
+ }
+}
?>
\ No newline at end of file