-small svc_dsl UI and flow changes, RT7111
[freeside.git] / httemplate / search / qual.cgi
1 <% include( '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 {
25                                           my $self = shift;
26                                           my $cust_or_prospect = $self->cust_or_prospect;
27                                           return $cust_or_prospect->name 
28                                             if $cust_or_prospect->get('custnum');
29                                           return "Prospect #".$cust_or_prospect->prospectnum
30                                             if $cust_or_prospect->get('prospectnum');
31                                           '';
32                                       },
33                                       'phonenum',
34                                       sub {
35                                         my $self = shift;
36                                         my %location_hash = $self->location;
37                                         # ugh...
38                                         if ( %location_hash ) {
39                                             my $loc = new FS::cust_location(\%location_hash); 
40                                             return $loc->location_label;
41                                         }
42                                         '';
43                                       },
44                                       sub {
45                                           my $self = shift;
46                                           my $export = $self->export;
47                                           my $result = '(manual)';
48                                           $result = $export->exportname if $export;
49                                           $result;
50                                       },
51                                       'vendor_qual_id',
52                                     ],
53                  'links'         => [
54                                       [ "${p}view/qual.cgi?qualnum=", 'qualnum' ],
55                                       '',
56                                       '',
57                                       '',
58                                       '',
59                                       '',
60                                       '',
61                                     ],
62       )
63 %>
64 <%init>
65
66 die "access denied"
67   unless $FS::CurrentUser::CurrentUser->access_right('Qualify service');
68
69 my $hashref = {};
70 my $count_query = 'SELECT COUNT(*) FROM qual';
71
72 my $extra_sql = '';
73 if ( $cgi->param('custnum') && $cgi->param('custnum') =~ /^(\d+)$/ ) {
74     $extra_sql = " where custnum = $1 or locationnum in "
75             . " (select locationnum from cust_location where custnum = $1)";
76 }
77
78 </%init>