stray closing /TABLE in the no-ticket case
[freeside.git] / httemplate / elements / searchbar-combined.html
1 <DIV STYLE="display:inline;
2             padding:3px 7px;
3             font-size:16px;
4             float:right;
5             border:1px solid #cccccc">
6 Search
7 <FORM ACTION="<%$fsurl%>search/searchbar.cgi" 
8       METHOD="GET" 
9       STYLE="margin:0; display:inline">
10   <SCRIPT TYPE="text/javascript">
11 var hints=new Array(<% join(',', map {"'$hints{$_}'"} @searches) |n%>);
12 function update_hint() {
13   var s = document.getElementById('search_for');
14   var q = document.getElementById('q');
15   q.value = hints[s.selectedIndex];
16 }
17 function clear_hint() {
18   var s = document.getElementById('search_for');
19   var q = document.getElementById('q');
20   if ( q.value == hints[s.selectedIndex] ) {
21     q.value = '';
22   }
23 }
24   </SCRIPT>
25   <SELECT NAME="search_for" id="search_for" STYLE="width:auto" onchange="update_hint()">
26 % foreach (@searches) {
27     <OPTION NAME="<% $_ %>"><% $_ %></OPTION>
28 % }
29   </SELECT>
30   <INPUT NAME="q" ID="q" TYPE="text" STYLE="width:140px" VALUE="<% $hints{$searches[0]} %>" onmousedown="clear_hint()">
31   <INPUT TYPE="submit" VALUE="Search" STYLE="width:auto">
32 </FORM>
33 </DIV>
34 <%init>
35 my $curuser = $FS::CurrentUser::CurrentUser;
36 my @searches = ();
37 push @searches, 'customers' if $curuser->access_right('List customers');
38 push @searches, 'prospects' if $curuser->access_right('List prospects');
39 push @searches, 'invoices'  if $curuser->access_right('View invoices');
40 push @searches, 'services'  if $curuser->access_right('View customer services');
41 push @searches, 'tickets'   if FS::Conf->new->exists('ticket_system');
42
43 my %hints = (
44   'customers' => '(cust #, name, company)',
45   'prospects' => '(name, company, phone)',
46   'invoices'  => '(invoice #)',
47   'services'  => '(user, email, phone...)',
48   'tickets'   => '(ticket #, subject, email)',
49 );
50
51 </%init>