summaryrefslogtreecommitdiff
path: root/httemplate/misc/change_pkg.cgi
blob: 16b7071214473b5c8f77a2135221c6fd50284d31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<% include('/elements/header-popup.html', "Change Package") %>

<% include('/elements/error.html') %>

<FORM ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST>
<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">

<% ntable('#cccccc') %>

  <TR>
    <TH ALIGN="right">Current package</TH>
    <TD COLSPAN=7>
      <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %>
    </TD>
  </TR>

  <% include('/elements/tr-select-cust-part_pkg.html',
               'pre_label'  => 'New',
               'curr_value' => scalar($cgi->param('pkgpart')),
               'classnum'   => $part_pkg->classnum,
               'cust_main'  => $cust_main,
               #'extra_sql'    => ' AND pkgpart != '. $cust_pkg->pkgpart,
            )
  %>

  <% include('/elements/tr-select-cust_location.html',
               'cgi'       => $cgi,
               'cust_main' => $cust_main,
            )
  %>

</TABLE>

<BR>
<INPUT TYPE="submit" VALUE="Change package">

</FORM>
</BODY>
</HTML>

<%init>

my $conf = new FS::Conf;

my $curuser = $FS::CurrentUser::CurrentUser;

die "access denied"
  unless $curuser->access_right('Change customer package');

my $pkgnum = scalar($cgi->param('pkgnum'));
$pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
$pkgnum = $1;

my $cust_pkg =
  qsearchs({
    'table'     => 'cust_pkg',
    'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
    'hashref'   => { 'pkgnum' => $pkgnum },
    'extra_sql' => ' AND '. $curuser->agentnums_sql,
  }) or die "unknown pkgnum $pkgnum";

my $cust_main = $cust_pkg->cust_main
  or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
         " ( pkgnum ". cust_pkg->pkgnum. ")";

my $part_pkg = $cust_pkg->part_pkg;

</%init>