CDR Report: add top sources, top destinations, and longest calls report options,...
[freeside.git] / httemplate / view / svc_acct.cgi
1 % if ( $custnum ) { 
2
3   <& /elements/header.html, mt("View [_1] account",$svc) &>
4   <& /elements/small_custview.html, $custnum, '', 1,
5      "${p}view/cust_main.cgi" &> 
6   <BR>
7
8 % } else { 
9 % my $delmsg = emt('Permanently delete this account?');
10
11   <SCRIPT>
12   function areyousure(href) {
13       if (confirm(<% $delmsg |js_string %>) == true)
14           window.location.href = href;
15   }
16   </SCRIPT>
17   
18   <& /elements/header.html, mt('View account'), menubar(
19     emt("Cancel this (unaudited) account") =>
20             "javascript:areyousure(\'${p}misc/cancel-unaudited.cgi?$svcnum\')",
21   ) &>
22
23 % } 
24
25 <& svc_acct/radius_usage.html,
26               'svc_acct' => $svc_acct,
27               'part_svc' => $part_svc,
28               'cust_pkg' => $cust_pkg,
29               %gopt,
30 &>
31
32 <& svc_acct/change_svc_form.html,
33               'part_svc' => \@part_svc,
34               'svcnum'   => $svcnum,
35               'pkgnum'   => $pkgnum,
36               %gopt,
37 &>
38
39 <% mt('Service #') |h %><B><% $svcnum %></B>
40 |
41 <& /view/elements/svc_edit_link.html, 'svc' => $svc_acct &>
42 <& svc_acct/change_svc.html,
43               'part_svc' => \@part_svc,
44               %gopt,
45 &>
46
47 <& svc_acct/basics.html,
48               'svc_acct' => $svc_acct,
49               'part_svc' => $part_svc,
50               %gopt,
51 &>
52
53 </FORM>
54 <BR>
55
56 <& svc_acct/cardfortress.html,
57               'svc_acct' => $svc_acct,
58               %gopt,
59 &>
60
61 <& svc_acct/hosting.html,
62               %gopt,
63 &>
64
65 %#remove this?  does anybody even use it?  it was a misunderstood customer
66 %#request IIRC?
67 % my $conf = new FS::Conf;
68 % if ( $conf->exists('svc_acct-notes') ) {
69 %   warn 'WARNING: svc_acct-notes deprecated\n';
70 <% join("<BR>", $conf->config('svc_acct-notes') ) %>
71 <BR><BR>
72 % }
73
74 <& elements/svc_export_settings.html, $svc_acct &>
75
76 <% joblisting({'svcnum'=>$svcnum}, 1) %>
77
78 <& /elements/footer.html &>
79 <%init>
80
81 die "access denied"
82   unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
83
84 my $addl_from = ' LEFT JOIN cust_svc  USING ( svcnum  ) '.
85                 ' LEFT JOIN cust_pkg  USING ( pkgnum  ) '.
86                 ' LEFT JOIN cust_main USING ( custnum ) ';
87
88 my($query) = $cgi->keywords;
89 $query =~ /^(\d+)$/;
90 my $svcnum = $1;
91 my $svc_acct = qsearchs({
92   'select'    => 'svc_acct.*',
93   'table'     => 'svc_acct',
94   'addl_from' => $addl_from,
95   'hashref'   => { 'svcnum' => $svcnum },
96   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql(
97                             'null_right' => 'View/link unlinked services'
98                           ),
99 });
100 die "Unknown svcnum" unless $svc_acct;
101
102 #false laziness w/all svc_*.cgi
103 my $cust_svc = $svc_acct->cust_svc;
104 my $pkgnum = $cust_svc->getfield('pkgnum');
105 my($cust_pkg, $custnum);
106 if ($pkgnum) {
107   $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } );
108   $custnum = $cust_pkg->custnum;
109 } else {
110   $cust_pkg = '';
111   $custnum = '';
112 }
113 #eofalse
114
115 my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } );
116 die "Unknown svcpart" unless $part_svc;
117 my $svc = $part_svc->svc;
118
119 my @part_svc = ();
120 if ($FS::CurrentUser::CurrentUser->access_right('Change customer service')) {
121
122   if ( $pkgnum ) { 
123     @part_svc = grep {    $_->svcdb   eq 'svc_acct'
124                        && $_->svcpart != $part_svc->svcpart }
125                 $cust_pkg->available_part_svc;
126   } else {
127     @part_svc = qsearch('part_svc', {
128       svcdb    => 'svc_acct',
129       disabled => '',
130       svcpart  => { op=>'!=', value=>$part_svc->svcpart },
131     } );
132   }
133
134 }
135
136 my $communigate = scalar($part_svc->part_export('communigate_pro'));
137                 # || scalar($part_svc->part_export('communigate_pro_singledomain'));
138
139 my %gopt = ( 'communigate' => $communigate,
140            );
141
142 </%init>