multi-select for agent on RADIUS usage report, RT#73050
[freeside.git] / httemplate / search / qual.cgi
1 <& elements/search.html,
2                  'title'         => 'Qualifications',
3                  'name_singular' => 'qualification',
4                  'query'         => { 'table'     => 'qual',
5                                       'hashref'   => $hashref,
6                                       'extra_sql' => $extra_sql,
7                                       'order_by'  => 'ORDER BY qualnum DESC',
8                                     },
9                  'count_query'   => "$count_query $extra_sql",
10                  'header'        => [ 'Qualification',
11                                       'Status',
12                                       'Customer or Prospect',
13                                       'Service Telephone Number',
14                                       'Address',
15                                       'Qualified Using',
16                                       'Vendor Qualification #',
17                                     ],
18                  'align'         => 'rcccccc',
19                  'fields'        => [ 'qualnum',
20                                       sub {
21                                         my $self = shift;
22                                         $self->status_long;
23                                       },
24                                       sub { shift->cust_or_prospect->name },
25                                       sub { shift->phonenum || '(none - dry loop)' },
26                                       sub {
27                                         my $self = shift;
28                                         my %location_hash= $self->location_hash;
29                                         # ugh...
30                                         if ( %location_hash ) {
31                                             my $loc = new FS::cust_location(\%location_hash); 
32                                             return $loc->location_label;
33                                         }
34                                         '';
35                                       },
36                                       sub {
37                                           my $self = shift;
38                                           my $export = $self->part_export;
39                                           my $result = '(manual)';
40                                           $result = $export->exportname if $export;
41                                           $result;
42                                       },
43                                       'vendor_qual_id',
44                                     ],
45                  'links'         => [
46                                       [ "${p}view/qual.cgi?qualnum=", 'qualnum' ],
47                                       '',
48                                       '',
49                                       '',
50                                       '',
51                                       '',
52                                       '',
53                                     ],
54       
55 &>
56 <%init>
57
58 die "access denied"
59   unless $FS::CurrentUser::CurrentUser->access_right('Qualify service');
60
61 my $hashref = {};
62 my $count_query = 'SELECT COUNT(*) FROM qual';
63
64 my $extra_sql = '';
65 if ( $cgi->param('custnum') && $cgi->param('custnum') =~ /^(\d+)$/ ) {
66     $extra_sql = " where custnum = $1 or locationnum in "
67             . " (select locationnum from cust_location where custnum = $1)";
68 } elsif ( $cgi->param('prospectnum') 
69         && $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
70     $extra_sql = " where prospectnum = $1 or locationnum in "
71             . " (select locationnum from cust_location where prospectnum = $1)";
72 }
73
74 </%init>