Added inactive record support.
[fa-stable.git] / includes / ui / ui_input.inc
index a85f41a8f3af6285c8a1bf35280fe1887b3532c6..82279aeaa4dcbb5f12306c42519ab22e127fffee 100644 (file)
@@ -199,14 +199,6 @@ function submit_add_or_update_center($add=true, $title=false, $async=false)
        echo "</center>";
 }
 
-/*
-function submit_add_or_update_row($add=true)
-{
-       echo "<tr><td colspan=99 align=center>";
-       submit_add_or_update($add);
-       echo "</td></tr>\n";
-}
-*/
 function submit_add_or_update_row($add=true, $right=true, $extra="", $title=false, $async=false)
 {
        echo "<tr>";
@@ -327,7 +319,7 @@ function check_cells($label, $name, $value, $submit_on_change=false, $title=fals
 {
        if ($label != null)
                echo "<td>$label</td>\n";
-       echo "<td>";
+       echo "<td align='center'>";
        echo check(null, $name, $value, $submit_on_change, $title);
        echo "</td>";
 }
@@ -486,22 +478,38 @@ 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="")
 {
-       text_row("<a href='Mailto:".$_POST[$name]."'>$label</a>", $name, $value, $size, $max, $title, $params, $post_label);
+       if (get_post($name)) 
+               $label = "<a href='Mailto:".$_POST[$name]."'>$label</a>";
+       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)
 {
-       text_row_ex("<a href='Mailto:".$_POST[$name]."'>$label</a>", $name, $size, $max, $title, $value, $params, $post_label);
+       if (get_post($name)) 
+               $label = "<a href='Mailto:".$_POST[$name]."'>$label</a>";
+       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="")
 {
-       text_row("<a href='".$_POST[$name]."' target='_blank'>$label</a>", $name, $value, $size, $max, $title, $params, $post_label);
+       $val = get_post($name);
+       if ($val) {
+               if (strpos($val,'http://')===false)
+                       $val = 'http://'.$val;
+               $label = "<a href='$val' target='_blank'>$label</a>";
+       }
+       text_row($label, $name, $value, $size, $max, $title, $params, $post_label);
 }
 
 function link_row_ex($label, $name, $size, $max=null, $title=null, $value=null, $params=null, $post_label=null)
 {
-       text_row_ex("<a href='".$_POST[$name]."' target='_blank'>$label</a>", $name, $size, $max, $title, $value, $params, $post_label);
+       $val = get_post($name);
+       if ($val) {
+               if (strpos($val,'http://')===false)
+                       $val = 'http://'.$val;
+               $label = "<a href='$val' target='_blank'>$label</a>";
+       }
+       text_row_ex($label, $name, $size, $max, $title, $value, $params, $post_label);
 }
 
 //-----------------------------------------------------------------------------------
@@ -741,6 +749,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 '<td align="center">'. checkbox(null, $name, $value, true, '')
+                       . hidden("LInact[$id]", $value, false) . '</td>';       
+       }
+}
+//
+//     Displays controls for optional display of inactive records
+//
+function inactive_control_row($th) {
+       echo  "<tr><td colspan=".(count($th)).">"
+               ."<div style='float:left;'>"
+               . checkbox(null, 'show_inactive', null, true). _("Show also Inactive")
+               ."</div><div style='float:right;'>"
+               . submit('Update', _('Update'), false, '', null)
+               ."</div></td></tr>";
+}
+//
+//     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