break out get_groups_dropdown to call a function called get_dropdown_options to populate thje options
parent
92c34f6043
commit
944298428a
|
@ -135,7 +135,7 @@ public $defaults = array(
|
||||||
return $this->{'MonitorIds'};
|
return $this->{'MonitorIds'};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_group_dropdown() {
|
public static function get_group_dropdown( ) {
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
$selected_group_id = 0;
|
$selected_group_id = 0;
|
||||||
|
@ -148,13 +148,23 @@ public $defaults = array(
|
||||||
}
|
}
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
|
||||||
|
return htmlSelect( 'Group[]', Group::get_dropdown_options(), isset($_SESSION['Group'])?$_SESSION['Group']:null, array(
|
||||||
|
'onchange' => 'this.form.submit();',
|
||||||
|
'class'=>'chosen',
|
||||||
|
'multiple'=>'multiple',
|
||||||
|
'data-placeholder'=>'All',
|
||||||
|
) );
|
||||||
|
|
||||||
|
} # end public static function get_group_dropdown
|
||||||
|
|
||||||
|
public static function get_dropdown_options() {
|
||||||
$Groups = array();
|
$Groups = array();
|
||||||
foreach ( Group::find_all( ) as $Group ) {
|
foreach ( Group::find_all( ) as $Group ) {
|
||||||
$Groups[$Group->Id()] = $Group;
|
$Groups[$Group->Id()] = $Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
# This array is indexed by parent_id
|
# This array is indexed by parent_id
|
||||||
global $children;
|
global $children;
|
||||||
$children = array();
|
$children = array();
|
||||||
|
|
||||||
foreach ( $Groups as $id=>$Group ) {
|
foreach ( $Groups as $id=>$Group ) {
|
||||||
|
@ -181,16 +191,10 @@ global $children;
|
||||||
$group_options += get_options( $Group );
|
$group_options += get_options( $Group );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return htmlSelect( 'Group[]', $group_options, isset($_SESSION['Group'])?$_SESSION['Group']:null, array(
|
return $group_options;
|
||||||
'onchange' => 'this.form.submit();',
|
}
|
||||||
'class'=>'chosen',
|
|
||||||
'multiple'=>'multiple',
|
|
||||||
'data-placeholder'=>'All',
|
|
||||||
) );
|
|
||||||
|
|
||||||
} # end public static function get_group_dropdown
|
public static function get_group_dropdowns( $selected = null ) {
|
||||||
|
|
||||||
public static function get_group_dropdowns() {
|
|
||||||
# This will end up with the group_id of the deepest selection
|
# This will end up with the group_id of the deepest selection
|
||||||
$group_id = 0;
|
$group_id = 0;
|
||||||
$depth = 0;
|
$depth = 0;
|
||||||
|
@ -205,6 +209,7 @@ global $children;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
$parent_group_ids = array();
|
$parent_group_ids = array();
|
||||||
|
if ( ! $selected ) {
|
||||||
$selected_group_id = 0;
|
$selected_group_id = 0;
|
||||||
if ( isset($_REQUEST['group'.$depth]) ) {
|
if ( isset($_REQUEST['group'.$depth]) ) {
|
||||||
$selected_group_id = $group_id = $_SESSION['group'.$depth] = $_REQUEST['group'.$depth];
|
$selected_group_id = $group_id = $_SESSION['group'.$depth] = $_REQUEST['group'.$depth];
|
||||||
|
@ -213,6 +218,9 @@ global $children;
|
||||||
} else if ( isset($_REQUEST['filtering']) ) {
|
} else if ( isset($_REQUEST['filtering']) ) {
|
||||||
unset($_SESSION['group'.$depth]);
|
unset($_SESSION['group'.$depth]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$selected_group_id = $selected;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ( $Groups as $Group ) {
|
foreach ( $Groups as $Group ) {
|
||||||
if ( ! isset( $groups[$depth] ) ) {
|
if ( ! isset( $groups[$depth] ) ) {
|
||||||
|
|
Loading…
Reference in New Issue