diff options
author | Ivan Kohler <ivan@freeside.biz> | 2015-01-07 14:30:15 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2015-01-07 14:30:15 -0800 |
commit | ceeaad3d99869f159bf2fee490aafa4c95d03365 (patch) | |
tree | e5026eeb4204e34fe0b49fe57e0d9412a594b397 | |
parent | 7a577311abdb174c4a5b52bd5f0d751931097efd (diff) |
add city search, RT#31659
-rw-r--r-- | FS/FS/cust_main/Search.pm | 12 | ||||
-rw-r--r-- | httemplate/elements/city.html | 87 | ||||
-rw-r--r-- | httemplate/elements/select-country.html | 4 | ||||
-rw-r--r-- | httemplate/elements/select-county.html | 22 | ||||
-rwxr-xr-x | httemplate/search/cust_main.html | 2 | ||||
-rwxr-xr-x | httemplate/search/report_cust_main.html | 114 |
6 files changed, 156 insertions, 85 deletions
diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm index 461633a..f0a7d41 100644 --- a/FS/FS/cust_main/Search.pm +++ b/FS/FS/cust_main/Search.pm @@ -728,6 +728,18 @@ sub search { } ## + # city + ## + if ( $params->{'city'} =~ /\S/ ) { + my $city = dbh->quote($params->{'city'}); + push @where, "EXISTS( + SELECT 1 FROM cust_location + WHERE cust_location.custnum = cust_main.custnum + AND cust_location.city = $city + )"; + } + + ## # county ## if ( $params->{'county'} =~ /\S/ ) { diff --git a/httemplate/elements/city.html b/httemplate/elements/city.html index 6a2142f..5f4d4e0 100644 --- a/httemplate/elements/city.html +++ b/httemplate/elements/city.html @@ -2,22 +2,24 @@ Example: - include( '/elements/city.html', - #recommended - country => $current_country, - state => $current_state, - county => $current_county, - city => $current_city, - - #optional - prefix => $optional_unique_prefix, - onchange => $javascript, - disabled => 0, #bool -# disable_empty => 1, #defaults to 1, disable the empty option -# empty_label => 'all', #label for empty option -# disable_select => 1, # disable the selector (just show a text input) - style => [ 'attribute:value', 'another:value' ], - ); + <& /elements/city.html, + #recommended + country => $current_country, + state => $current_state, + county => $current_county, + city => $current_city, + + #optional + prefix => $optional_unique_prefix, + onchange => $javascript, + disabled => 0, #bool + style => [ 'attribute:value', 'another:value' ], + disable_empty => 1, #defaults to 1, set to 0 to disable the empty option + empty_label => 'all', #label for empty option + disable_text => 1, # disable the text input (just show the select) + #doesn't work as an option yet, set when conf tax_district_method + #disable_select => 1, # disable the selector (just show a text input) + &> </%doc> @@ -47,16 +49,22 @@ function <% $pre %>county_changed(what, callback) {} function <% $pre %>county_changed(what, callback) { + what.form.<% $pre %>city_select.disabled = 'disabled'; + county = what.options[what.selectedIndex].value; state = what.form.<% $pre %>state.options[what.form.<% $pre %>state.selectedIndex].value; country = what.form.<% $pre %>country.options[what.form.<% $pre %>country.selectedIndex].value; function <% $pre %>update_cities(cities) { - + // blank the current city list for ( var i = what.form.<% $pre %>city_select.length; i >= 0; i-- ) what.form.<% $pre %>city_select.options[i] = null; +% unless ( $opt{disable_empty} ) { + opt( what.form.<% $pre %>city_select, '', <% $opt{empty_label} |js_string %> ); +% } + // add the new cities var citiesArray = eval('(' + cities + ')' ); @@ -67,7 +75,7 @@ function <% $pre %>county_changed(what, callback) {} opt(what.form.<% $pre %>city_select, citiesArray[s], cityLabel); } - if ( citiesArray.length > 1 || citiesArray[0].length ) { + if ( citiesArray.length > 1 || (citiesArray[0] && citiesArray[0].length) ){ // turn off the text city, turn on the select saved_<%$pre%>city = what.form.<%$ pre %>city.value; <%$pre%>city_select_changed(what.form.<% $pre %>city_select); @@ -80,6 +88,8 @@ function <% $pre %>county_changed(what, callback) {} what.form.<% $pre %>city_select.style.display = 'none'; } + what.form.<% $pre %>city_select.disabled = ''; + //run the callback if ( callback != null ) callback(); @@ -98,39 +108,44 @@ function <% $pre %>county_changed(what, callback) {} % } #!disable_select -<INPUT TYPE = "text" +<INPUT TYPE = "<% $opt{disable_text} ? 'hidden' : 'text' %>" NAME = "<%$pre%>city" ID = "<%$pre%>city" VALUE = "<% $opt{'city'} |h %>" +% unless ( $opt{disable_text} ) { onChange = "<% $opt{'onchange'} %>" <% $opt{'disabled'} %> <% $text_style %> +% } > % if ( $disable_select ) { %# avoid JS errors -<INPUT TYPE="hidden" ID="city_select"> -% } -% else { + <INPUT TYPE="hidden" ID="city_select"> +% } else { -<SELECT NAME = "<%$pre%>city_select" - ID = "<%$pre%>city_select" - onChange = "<%$pre%>city_select_changed(this); <% $opt{'onchange'} %>" - <% $opt{'disabled'} %> - <% $select_style %> -> + <SELECT NAME = "<%$pre%>city_select" + ID = "<%$pre%>city_select" + onChange = "<%$pre%>city_select_changed(this); <% $opt{onchange} %>" + <% $opt{disabled} %> + <% $select_style %> + > -% foreach my $city ( @cities ) { +% unless ( $opt{'disable_empty'} ) { + <OPTION VALUE="" <% $opt{city} eq '' ? 'SELECTED' : '' %>><% $opt{empty_label} %> +% } - <OPTION VALUE="<% $city |h %>" - <% $city eq $opt{'city'} ? 'SELECTED' : '' %> - ><% $city eq $opt{'empty_data_value'} ? $opt{'empty_data_label'} : $city %> +% foreach my $city ( @cities ) { -% } + <OPTION VALUE="<% $city |h %>" + <% $city eq $opt{city} ? 'SELECTED' : '' %> + ><% $city eq $opt{empty_data_value} ? $opt{empty_data_label} : $city %> -</SELECT> +% } + + </SELECT> % } -%# VALUE = "<% $curr_value |h %>" + <%init> my %opt = @_; @@ -142,6 +157,8 @@ my $conf = new FS::Conf; # tax district table. my $disable_select = 1 if $conf->config('tax_district_method'); +$opt{'disable_empty'} = 1 unless exists($opt{'disable_empty'}); + my $text_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : []; my $select_style = $opt{'style'} ? [ @{ $opt{'style'} } ] : []; diff --git a/httemplate/elements/select-country.html b/httemplate/elements/select-country.html index 724afe3..f3d9876 100644 --- a/httemplate/elements/select-country.html +++ b/httemplate/elements/select-country.html @@ -40,6 +40,8 @@ Example: } function <% $pre %>country_changed(what, callback) { + + what.form.<% $pre %>state.disabled = 'disabled'; country = what.options[what.selectedIndex].value; @@ -61,6 +63,8 @@ Example: stateLabel = <% $opt{state_empty_label} || '(n/a)' |js_string %>; opt(what.form.<% $pre %>state, statesArray[s], stateLabel); } + + what.form.<% $pre %>state.disabled = ''; //run the callback if ( callback != null ) { diff --git a/httemplate/elements/select-county.html b/httemplate/elements/select-county.html index 058993f..cce085f 100644 --- a/httemplate/elements/select-county.html +++ b/httemplate/elements/select-county.html @@ -12,7 +12,7 @@ Example: prefix => $optional_unique_prefix, onchange => $javascript, disabled => 0, #bool - disable_empty => 1, #defaults to 1, disable the empty option + disable_empty => 1, #defaults to 1, set to 0 to disable the empty option empty_label => 'all', #label for empty option style => [ 'attribute:value', 'another:value' ], &> @@ -36,6 +36,8 @@ Example: function <% $pre %>state_changed(what, callback) { + what.form.<% $pre %>county.disabled = 'disabled'; + state = what.options[what.selectedIndex].value; country = what.form.<% $pre %>country.options[what.form.<% $pre %>country.selectedIndex].value; @@ -44,6 +46,10 @@ Example: // blank the current county list for ( var i = what.form.<% $pre %>county.length; i >= 0; i-- ) what.form.<% $pre %>county.options[i] = null; + +% unless ( $opt{disable_empty} ) { + opt( what.form.<% $pre %>county, '', <% $opt{empty_label} |js_string %> ); +% } // add the new counties var countiesArray = eval('(' + counties + ')' ); @@ -58,14 +64,20 @@ Example: if ( countiesArray.length > 1 ) { what.form.<% $pre %>county.style.display = ''; - //countyFormLabel.style.visibility = 'visible'; - countyFormLabel.style.display = ''; + if ( countyFormLabel ) { + //countyFormLabel.style.visibility = 'visible'; + countyFormLabel.style.display = ''; + } } else { what.form.<% $pre %>county.style.display = 'none'; - //countyFormLabel.style.visibility = 'hidden'; - countyFormLabel.style.display = 'none'; + if ( countyFormLabel ) { + //countyFormLabel.style.visibility = 'hidden'; + countyFormLabel.style.display = 'none'; + } } + what.form.<% $pre %>county.disabled = ''; + //run the callback if ( callback != null ) { callback(); diff --git a/httemplate/search/cust_main.html b/httemplate/search/cust_main.html index 19456e6..503e782 100755 --- a/httemplate/search/cust_main.html +++ b/httemplate/search/cust_main.html @@ -41,7 +41,7 @@ my %search_hash = (); #scalars my @scalars = qw ( - agentnum salesnum status address county state zip country + agentnum salesnum status address city county state zip country paydate_year paydate_month invoice_terms no_censustract with_geocode with_email tax no_tax POST no_POST custbatch usernum diff --git a/httemplate/search/report_cust_main.html b/httemplate/search/report_cust_main.html index 2b40672..cacb7de 100755 --- a/httemplate/search/report_cust_main.html +++ b/httemplate/search/report_cust_main.html @@ -6,7 +6,7 @@ <TABLE BGCOLOR="#cccccc" CELLSPACING=0> <TR> - <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Search options') |h %></FONT></TH> + <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Basic search options') |h %></FONT></TH> </TR> <& /elements/tr-select-agent.html, @@ -40,48 +40,6 @@ &> <TR> - <TD ALIGN="right" VALIGN="center"><% mt('Address') |h %></TD> - <TD><INPUT TYPE="text" NAME="address" SIZE=54></TD> - </TR> - - <TR> - <TD ALIGN="right" VALIGN="center"><% mt('County') |h %></TD> - <TD> - <& /elements/select-county.html, - disable_empty => 0, - empty_label => '(all)', - &> - </TD> - </TR> - - - <TR> - <TD ALIGN="right" VALIGN="center"><% mt('State') |h %></TD> - <TD> - <& /elements/select-state.html, - disable_empty => 0, - empty_label => '(all)', - &> - </TD> - </TR> - - <TR> - <TD ALIGN="right" VALIGN="center"><% mt('Zip') |h %></TD> - <TD><INPUT TYPE="text" NAME="zip" SIZE=12></TD> - </TR> - - <TR> - <TD ALIGN="right" VALIGN="center"><% mt('Country') |h %></TD> - <TD> - <& /elements/select-country.html, - disable_empty => 0, - state_disable_empty => 0, - state_empty_label => '(all)', - &> - </TD> - </TR> - - <TR> <TD ALIGN="right" VALIGN="center"><% mt('Signup date') |h %></TD> <TD> <TABLE> @@ -168,6 +126,74 @@ </TD> </TR> + <TR> + <TH CLASS="background" COLSPAN=2> </TH> + </TR> + + <TR> + <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Location search options') |h %></FONT></TH> + </TR> + + <TR> + <TD ALIGN="right" VALIGN="center"><% mt('Address') |h %></TD> + <TD><INPUT TYPE="text" NAME="address" SIZE=54></TD> + </TR> + + <TR> + <TD ALIGN="right" VALIGN="center"><% mt('City') |h %></TD> + <TD> + <& /elements/city.html, + disable_empty => 0, + empty_label => '(all)', + disable_text => 1, + &> + </TD> + </TR> + + <TR> + <TD ALIGN="right" VALIGN="center"><% mt('County') |h %></TD> + <TD> + <& /elements/select-county.html, + disable_empty => 0, + empty_label => '(all)', + &> + </TD> + </TR> + + <TR> + <TD ALIGN="right" VALIGN="center"><% mt('State') |h %></TD> + <TD> + <& /elements/select-state.html, + disable_empty => 0, + empty_label => '(all)', + &> + </TD> + </TR> + + <TR> + <TD ALIGN="right" VALIGN="center"><% mt('Zip') |h %></TD> + <TD><INPUT TYPE="text" NAME="zip" SIZE=12></TD> + </TR> + + <TR> + <TD ALIGN="right" VALIGN="center"><% mt('Country') |h %></TD> + <TD> + <& /elements/select-country.html, + disable_empty => 0, + state_disable_empty => 0, + state_empty_label => '(all)', + &> + </TD> + </TR> + + <TR> + <TH CLASS="background" COLSPAN=2> </TH> + </TR> + + <TR> + <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1"><% mt('Billing search options') |h %></FONT></TH> + </TR> + <& /elements/tr-select-payby.html, 'payby_type' => 'cust', 'multiple' => 1, @@ -252,7 +278,7 @@ &> <TR> - <TD ALIGN="right" VALIGN="center"><% mt('With email address(es)') |h %></TD> + <TD ALIGN="right" VALIGN="center"><% mt('With invoicing email address(es)') |h %></TD> <TD><INPUT TYPE="checkbox" NAME="with_email"></TD> </TR> |