diff --git a/html/ajax_search.php b/html/ajax_search.php index 7d82a1ac9e..13328fce18 100644 --- a/html/ajax_search.php +++ b/html/ajax_search.php @@ -318,6 +318,17 @@ if (isset($_REQUEST['search'])) { $json = json_encode($device); die($json); + } + else if ($_REQUEST['type'] == 'bill') { + // Device search + if (is_admin() === true || is_read() === true) { + $results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` WHERE `bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%' LIMIT 8"); + } + else { + $results = dbFetchRows("SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` INNER JOIN `bill_perms` ON `bills`.bill_id = `bill_perms`.bill_id WHERE `bill_perms`.user_id = ? AND (`bill_name` LIKE '%".$search."%' OR `bill_notes` LIKE '%".$search."%')LIMIT 8", array($_SESSION['user_id'], $_SESSION['user_id'])); + } + $json = json_encode($results); + die($json); }//end if }//end if }//end if diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index e7cf4b9ed2..87bb883738 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -66,6 +66,8 @@ if( defined('show_settings') || empty($widget_settings) ) { + +
@@ -140,6 +142,14 @@ if( defined('show_settings') || empty($widget_settings) ) { $common_output[] = '
+
+
+ +
+
+ +
+
@@ -301,6 +311,40 @@ function '.$unique_id.'() { } }); + var '.$unique_id.'_bill = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace("munin"), + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + url: "ajax_search.php?search=%QUERY&type=bill", + filter: function (output) { + return $.map(output, function (item) { + return { + name: item.bill_name, + bill_id: item.bill_id, + }; + }); + }, + wildcard: "%QUERY" + } + }); + '.$unique_id.'_bill.initialize(); + $(".input_'.$unique_id.'_bill").typeahead({ + hint: true, + highlight: true, + minLength: 1, + classNames: { + menu: "typeahead-left" + } + }, + { + source: '.$unique_id.'_bill.ttAdapter(), + async: false, + templates: { + header: "
 Bill
", + suggestion: Handlebars.compile(\'

{{name}}

\') + } + }); + switch_'.$unique_id.'($("#select_'.$unique_id.'").val()); } function switch_'.$unique_id.'(data) {