+sub collapse_link {
+ my %param = @_;
+
+ my $row = $param{'row'};
+ my $col = $param{'col'};
+ return ''
+ if $col eq 'county' and $row->city
+ || qsearch({
+ 'table' => 'cust_main_county',
+ 'hashref' => {
+ 'country' => $row->country,
+ 'state' => $row->state,
+ 'city' => { op=>'!=', value=>'' },
+ },
+ 'order_by' => 'LIMIT 1',
+ });
+
+ my %above = ( 'city' => 'county',
+ 'county' => 'state',
+ );
+
+ #XXX can still show the link when you have some counties broken down into
+ #cities and others not :/
+
+ my $taxnum = $param{'row'}->taxnum;
+ my $url = "${p}edit/process/cust_main_county-collapse.cgi?$taxnum";
+ $url = "javascript:collapse_areyousure('$url', '$col', '$above{$col}')";
+
+ qq(<FONT SIZE="-1"><A HREF="$url">$param{'label'}</A></FONT>);
+}
+
+