[drupal] use tableselect option of the elements module for sensor selection

This commit is contained in:
Bart Van Der Meerssche 2011-03-17 23:52:13 +00:00
parent c8414867bd
commit 1b26bf0e8c
1 changed files with 30 additions and 17 deletions

View File

@ -845,37 +845,50 @@ function _logger_sensors_form() {
$i = 0; $i = 0;
$rows = array(); $rows = array();
$row = array(); $row = array();
$defaults = array();
while ($sensor = db_fetch_object($sensors)) { while ($sensor = db_fetch_object($sensors)) {
if ($sensor->chart) { $row['function'] = $sensor->function;
$row[] = l('[x]', 'logger/sensor/remove/' . $sensor->meter, array('attributes' => array('title' => "remove ". $sensor->function . " from the chart"), 'query' => $destination, 'alias' => TRUE)); $row['sensor'] = $sensor->meter;
} $row['access'] = unix_to_userlocaltime($sensor->access);
else { $row['counter'] = $sensor->value;
$row[] = l('[+]', 'logger/sensor/add/' . $sensor->meter, array('attributes' => array('title' => "add ". $sensor->function . " to the chart"), 'query' => $destination, 'alias' => TRUE));
} $rows[$sensor->meter] = $row;
$row[] = $sensor->function;
$row[] = $sensor->meter;
$row[] = unix_to_userlocaltime($sensor->access);
$row[] = $sensor->value;
$rows[] = $row;
$row = array(); $row = array();
if ($sensor->chart) {
$defaults[$sensor->meter] = TRUE;
}
$i++; $i++;
} }
$header = array(
'function' => t('Function'),
'sensor' => t('Sensor'),
'access' => t('Last Reporting'),
'counter' => t('Counter'),
);
$form['sensors'] = array( $form['sensors'] = array(
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Sensors'), '#title' => t('Sensors'),
'#description' => t('Select the sensors you wish to add to [+] or remove from [x] the chart.'), '#description' => t('Select the sensors you wish to add to the chart.'),
'#collapsible' => TRUE, '#collapsible' => TRUE,
'#collapsed' => TRUE, '#collapsed' => TRUE,
); );
$form['sensors']['list'] = array( $form['sensors']['list'] = array(
'#type' => 'item', '#type' => 'tableselect',
//'#title' => t('Title'), '#header' => $header,
'#value' => theme('table', array(t('Chart'), t('Function'), t('Sensor'), t('Last Reporting'), t('Counter')), $rows), '#options' => $rows,
'#multiple' => TRUE,
'#default_value' => $defaults,
);
$form['sensors']['submit'] = array
(
'#type' => 'submit',
'#value' => t('Update'),
); );
return $form; return $form;