Merge branch 'master' of ../cloudmule
commit
24b8a9118d
|
@ -51,6 +51,8 @@ class Filter extends ZM_Object {
|
|||
if ($term->valid()) {
|
||||
if (!$this->_sql and $term->cnj) unset($term->cnj);
|
||||
$this->_sql .= $term->sql();
|
||||
} else {
|
||||
Debug("Term is not valid " . $term->to_string());
|
||||
}
|
||||
} # end foreach term
|
||||
}
|
||||
|
@ -174,7 +176,6 @@ class Filter extends ZM_Object {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->{'Query'} and isset($this->{'Query'}['terms']) and count($this->{'Query'}['terms'])) {
|
||||
unset($this->{'Query'}['terms'][0]['cnj']);
|
||||
}
|
||||
|
@ -959,18 +960,20 @@ class Filter extends ZM_Object {
|
|||
|
||||
#$html .= ($i == 0) ? '' : htmlSelect("filter[Query][terms][$i][cnj]", $conjunctionTypes, $term['cnj']).PHP_EOL;
|
||||
$html .= ($i == 0) ? '' : html_input("filter[Query][terms][$i][cnj]", 'hidden', $term['cnj']).PHP_EOL;
|
||||
$html .= '<span class="term"><label>'.html_input("filter[Query][terms][$i][attr]", 'hidden', $term['attr']).$attrTypes[$term['attr']].'</label>';
|
||||
if ( isset($term['attr']) ) {
|
||||
$html .= '<span class="term"><label>'.$attrTypes[$term['attr']].'</label>';
|
||||
$html .= html_input("filter[Query][terms][$i][attr]", 'hidden', $term['attr']);
|
||||
$html .= html_input("filter[Query][terms][$i][op]", 'hidden', '=').PHP_EOL;
|
||||
if ( $term['attr'] == 'Archived' ) {
|
||||
$html .= html_input("filter[Query][terms]['.$i.'][op]", 'hidden', '=').PHP_EOL;
|
||||
$html .= htmlSelect("filter[Query][terms][$i][val]", $archiveTypes, $term['val']).PHP_EOL;
|
||||
} else if ( $term['attr'] == 'DateTime' || $term['attr'] == 'StartDateTime' || $term['attr'] == 'EndDateTime') {
|
||||
$html .= '<span>'. $term['op'].'</span>'.PHP_EOL;
|
||||
#$html .= '<span>'.htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']).'</span>'.PHP_EOL;
|
||||
$html .= '<span><input type="text" class="datetimepicker" name="filter[Query][terms]['.$i.'][val]" id="filter[Query][terms]['.$i.'][val]" value="'.(isset($term['val'])?validHtmlStr(str_replace('T', ' ', $term['val'])):'').'"/></span>'.PHP_EOL;
|
||||
} else if ( $term['attr'] == 'Date' || $term['attr'] == 'StartDate' || $term['attr'] == 'EndDate' ) {
|
||||
$html .= '<span>'.htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']).'</span>'.PHP_EOL;
|
||||
$html .= '<span><input type="text" name="filter[Query][terms]['.$i.'][val]" id="filter[Query][terms]['.$i.'][val]" value="'.(isset($term['val'])?validHtmlStr($term['val']):'').'"/></span>'.PHP_EOL;
|
||||
$html .= '<span>'. $term['op'].'</span>'.PHP_EOL;
|
||||
#$html .= '<span>'.htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']).'</span>'.PHP_EOL;
|
||||
$html .= '<span><input type="text" class="datepicker" name="filter[Query][terms]['.$i.'][val]" id="filter[Query][terms]['.$i.'][val]" value="'.(isset($term['val'])?validHtmlStr($term['val']):'').'"/></span>'.PHP_EOL;
|
||||
} else if ( $term['attr'] == 'StartTime' || $term['attr'] == 'EndTime' ) {
|
||||
$html .= '<span>'.htmlSelect("filter[Query][terms][$i][op]", $opTypes, $term['op']).'</span>'.PHP_EOL;
|
||||
$html .= '<span><input type="text" name="filter[Query][terms]['.$i.'][val]" id="filter[Query][terms]['.$i.'][val]" value="'.(isset($term['val'])?validHtmlStr(str_replace('T', ' ', $term['val'])):'' ).'"/></span>'.PHP_EOL;
|
||||
|
|
|
@ -32,7 +32,8 @@ class FilterTerm {
|
|||
|
||||
$this->index = $index;
|
||||
if ($term) {
|
||||
$this->attr = $term['attr'];
|
||||
Debug(print_r($term, true));
|
||||
$this->attr = isset($term['attr']) ? $term['attr'] : '';
|
||||
$this->op = $term['op'];
|
||||
$this->val = $term['val'];
|
||||
if ( isset($term['cnj']) ) {
|
||||
|
@ -64,7 +65,7 @@ class FilterTerm {
|
|||
}
|
||||
} else {
|
||||
Warning("No term in FilterTerm constructor");
|
||||
Warning(print_r(debug_backtrace(), true));
|
||||
#Warning(print_r(debug_backtrace(), true));
|
||||
}
|
||||
} # end function __construct
|
||||
|
||||
|
@ -72,7 +73,7 @@ class FilterTerm {
|
|||
public function sql_values() {
|
||||
$values = array();
|
||||
if ( !isset($this->val) ) {
|
||||
Logger::Warning('No value in term'.$this->attr);
|
||||
Warning('No value in term'.$this->attr);
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
@ -206,6 +207,9 @@ class FilterTerm {
|
|||
|
||||
/* Some terms don't have related SQL */
|
||||
public function sql() {
|
||||
if (!$this->attr) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$sql = '';
|
||||
if ( isset($this->cnj) ) {
|
||||
|
@ -507,6 +511,8 @@ class FilterTerm {
|
|||
|
||||
public function valid() {
|
||||
switch ($this->attr) {
|
||||
case 'EndDate' :
|
||||
case 'StartDate' :
|
||||
case 'EndDateTime' :
|
||||
case 'StartDateTime' :
|
||||
if (!$this->val)
|
||||
|
@ -520,6 +526,9 @@ class FilterTerm {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public function to_string() {
|
||||
return print_r($this, true);
|
||||
}
|
||||
} # end class FilterTerm
|
||||
|
||||
?>
|
||||
|
|
|
@ -2221,11 +2221,14 @@ function array_recursive_diff($aArray1, $aArray2) {
|
|||
function html_input($name, $type='text', $value='', $options=array()) {
|
||||
$html = '<input ';
|
||||
$attributes = [];
|
||||
foreach (array_keys(array_merge($options,['name'=>$name, 'value'=>$value, 'type'=>$type])) as $k) {
|
||||
$options = array_merge($options, ['name'=>$name, 'value'=>$value, 'type'=>$type]);
|
||||
|
||||
foreach (array_keys($options) as $k) {
|
||||
$attributes[] = $k.'="'.$options[$k].'"';
|
||||
}
|
||||
$html .= join(' ', $attributes);
|
||||
$html .= '/>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
function html_radio($name, $values, $selected=null, $options=array(), $attrs=array()) {
|
||||
|
|
|
@ -38,8 +38,8 @@ $filter = isset($_REQUEST['filter_id']) ? new ZM\Filter($_REQUEST['filter_id'])
|
|||
if ( isset($_REQUEST['filter'])) {
|
||||
$filter->set($_REQUEST['filter']);
|
||||
} else if (!$filter->Id()) {
|
||||
$filter->addTerm(array('cnj'=>'and', 'attr'=>'StartDateTime', 'op'=> '>=', 'val'=>''));
|
||||
$filter->addTerm(array('cnj'=>'and', 'attr'=>'EndDateTime', 'op'=> '<=', 'val'=>''));
|
||||
$filter->addTerm(array('cnj'=>'and', 'attr'=>'StartDate', 'op'=> '=', 'val'=>''));
|
||||
#$filter->addTerm(array('cnj'=>'and', 'attr'=>'StartDateTime', 'op'=> '<=', 'val'=>''));
|
||||
$filter->addTerm(array('cnj'=>'and', 'attr'=>'Monitor', 'op'=> '=', 'val'=>''));
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ function ajaxRequest(params) {
|
|||
delete params.data.filter;
|
||||
}
|
||||
$j('#fieldsTable input').each(function(index) {
|
||||
console.log(this);
|
||||
const el = $j(this);
|
||||
params.data[el.attr('name')] = el.val();
|
||||
});
|
||||
|
@ -411,6 +410,9 @@ function initPage() {
|
|||
if (el.hasClass('datetimepicker')) {
|
||||
el.datetimepicker({timeFormat: "HH:mm:ss", dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false});
|
||||
}
|
||||
if (el.hasClass('datepicker')) {
|
||||
el.datepicker({dateFormat: "yy-mm-dd", maxDate: 0, constrainInput: false})
|
||||
}
|
||||
});
|
||||
|
||||
table.bootstrapTable('resetSearch');
|
||||
|
@ -419,10 +421,19 @@ function initPage() {
|
|||
}
|
||||
|
||||
function filterEvents() {
|
||||
filterQuery = '';
|
||||
$j('#fieldsTable input').each(function(index) {
|
||||
const el = $j(this);
|
||||
filterQuery += '&'+encodeURIComponent(el.attr('name'))+'='+encodeURIComponent(el.val());
|
||||
});
|
||||
$j('#fieldsTable select').each(function(index) {
|
||||
const el = $j(this);
|
||||
filterQuery += '&'+encodeURIComponent(el.attr('name'))+'='+encodeURIComponent(el.val());
|
||||
});
|
||||
console.log(filterQuery);
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
|
||||
|
||||
$j(document).ready(function() {
|
||||
initPage();
|
||||
});
|
||||
|
|
|
@ -43,6 +43,7 @@ $tabs['highband'] = translate('HighBW');
|
|||
$tabs['medband'] = translate('MediumBW');
|
||||
$tabs['lowband'] = translate('LowBW');
|
||||
$tabs['users'] = translate('Users');
|
||||
$tabs['groups'] = translate('Groups');
|
||||
$tabs['control'] = translate('Control');
|
||||
$tabs['privacy'] = translate('Privacy');
|
||||
$tabs['MQTT'] = translate('MQTT');
|
||||
|
@ -200,6 +201,14 @@ foreach (array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as $
|
|||
}
|
||||
// Have to do this
|
||||
header('Location: '.$redirect);
|
||||
} else if ($tab == 'groups') {
|
||||
if (canView('Groups')) {
|
||||
$redirect = '?view=groups';
|
||||
} else {
|
||||
$redirect = '?view=error';
|
||||
}
|
||||
// Have to do this
|
||||
header('Location: '.$redirect);
|
||||
} else if ($tab == 'servers') {
|
||||
?>
|
||||
<form name="serversForm" method="post" action="?">
|
||||
|
|
Loading…
Reference in New Issue