enable CardFortress in test database, #71513
[freeside.git] / httemplate / misc / disable-cust_location.cgi
1 <& /elements/header-popup.html, "Location disabled" &>
2   <SCRIPT TYPE="text/javascript">
3     topreload();
4   </SCRIPT>
5 </BODY>
6 </HTML>
7 <%init>
8
9 my $curuser = $FS::CurrentUser::CurrentUser;
10 my $error;
11
12 die "access denied"
13   unless $curuser->access_right('Change customer package');
14
15 my $locationnum = $cgi->param('locationnum');
16 my $cust_location = qsearchs({
17   'select'    => 'cust_location.*',
18   'table'     => 'cust_location',
19   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
20   'hashref'   => { 'locationnum' => $locationnum },
21   'extra_sql' => ' AND '. $curuser->agentnums_sql,
22 });
23 die "unknown locationnum $locationnum" unless $cust_location;
24
25 my @pkgs = qsearch('cust_pkg', { 'locationnum' => $locationnum,
26                                  'cancel'      => '' });
27 if ( @pkgs ) {
28   $error = "Location $locationnum has active packages"
29 }
30 else {
31   $cust_location->disabled('Y');
32   $error = $cust_location->replace;
33 }
34 die $error if $error;
35 </%init>